Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created August 22, 2022 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adatta02/fdc84c1ef510d86350b0be284627b6d7 to your computer and use it in GitHub Desktop.
Save adatta02/fdc84c1ef510d86350b0be284627b6d7 to your computer and use it in GitHub Desktop.
const fs = require('fs')
async function fileExists(path: string, flag: string): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
fs.access(path, fs.F_OK, (err) => {
if(err) {
resolve(false); // no file exists
}else{
resolve(true);
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment