Created
August 22, 2022 15:15
-
-
Save adatta02/fdc84c1ef510d86350b0be284627b6d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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