Skip to content

Commit

Permalink
Use fs.access
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 20, 2019
1 parent b75a6e0 commit 45533cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/babel-core/src/gensync-utils/fs.js
Expand Up @@ -9,6 +9,13 @@ export const readFile = gensync<[string, "utf8"], string>({
});

export const exists = gensync<[string], boolean>({
sync: fs.existsSync,
errback: (path, cb) => fs.exists(path, res => cb(null, res)),
sync(path) {
try {
fs.accessSync(path);
return true;
} catch {
return false;
}
},
errback: (path, cb) => fs.access(path, undefined, err => cb(null, !err)),
});

0 comments on commit 45533cf

Please sign in to comment.