diff options
Diffstat (limited to 'packages/sol-compiler/src/utils/fs_wrapper.ts')
-rw-r--r-- | packages/sol-compiler/src/utils/fs_wrapper.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/sol-compiler/src/utils/fs_wrapper.ts b/packages/sol-compiler/src/utils/fs_wrapper.ts index cc7b06175..8d6800276 100644 --- a/packages/sol-compiler/src/utils/fs_wrapper.ts +++ b/packages/sol-compiler/src/utils/fs_wrapper.ts @@ -10,4 +10,19 @@ export const fsWrapper = { doesPathExistSync: fs.existsSync, rmdirSync: fs.rmdirSync, removeFileAsync: promisify<undefined>(fs.unlink), + 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; + }, }; |