aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-compiler/src/utils
diff options
context:
space:
mode:
authorF. Eugene Aumson <gene@aumson.org>2018-08-17 06:26:20 +0800
committerF. Eugene Aumson <gene@aumson.org>2018-08-17 06:26:20 +0800
commit445177bf420049041ade4d7526a5f4a8194bd216 (patch)
tree39f93ce8394f25c3432f326b9e734c5b9f1b4ccd /packages/sol-compiler/src/utils
parent402ca27fbf91f543addf0d4618e071ae10cfd70e (diff)
downloaddexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar.gz
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar.bz2
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar.lz
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar.xz
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.tar.zst
dexon-sol-tools-445177bf420049041ade4d7526a5f4a8194bd216.zip
move doesFileExist to fsWrapper
Diffstat (limited to 'packages/sol-compiler/src/utils')
-rw-r--r--packages/sol-compiler/src/utils/fs_wrapper.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/sol-compiler/src/utils/fs_wrapper.ts b/packages/sol-compiler/src/utils/fs_wrapper.ts
index 44c97bd1e..8d6800276 100644
--- a/packages/sol-compiler/src/utils/fs_wrapper.ts
+++ b/packages/sol-compiler/src/utils/fs_wrapper.ts
@@ -13,4 +13,16 @@ export const fsWrapper = {
statAsync: promisify<fs.Stats>(fs.stat),
appendFileAsync: promisify<undefined>(fs.appendFile),
accessAsync: promisify<boolean>(fs.access),
+ doesFileExistAsync: async (filePath: string): Promise<boolean> => {
+ try {
+ await fsWrapper.accessAsync(
+ filePath,
+ // node says we need to use bitwise, but tslint says no:
+ fs.constants.F_OK | fs.constants.R_OK, // tslint:disable-line:no-bitwise
+ );
+ } catch (err) {
+ return false;
+ }
+ return true;
+ },
};