Skip to content

Commit

Permalink
perf: handle the case if the file is not present. (#812)
Browse files Browse the repository at this point in the history
Co-authored-by: ayush-coder-hai <ayush@betalectic.com>%0ACo-authored-by: souvik <souvikde.ns@gmail.com>
  • Loading branch information
ayushnau and Souvikns authored Oct 9, 2023
1 parent f00bd45 commit ba9df40
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/commands/new/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ export default class NewFile extends Command {
console.log(`File ${fileNameToWriteToDisk} already exists. Ignoring...`);
return;
}
} catch (e) {
// File does not exist. Proceed creating it...
} catch (e:any) {
if (e.code === 'EACCES') {
this.error('Permission denied to read the file. You do not have the necessary permissions.');
}
}

await writeFile(fileNameToWriteToDisk, asyncApiFile, { encoding: 'utf8' });
console.log(`Created file ${fileNameToWriteToDisk}...`);
}
Expand Down

0 comments on commit ba9df40

Please sign in to comment.