From 445177bf420049041ade4d7526a5f4a8194bd216 Mon Sep 17 00:00:00 2001 From: "F. Eugene Aumson" Date: Thu, 16 Aug 2018 15:26:20 -0700 Subject: move doesFileExist to fsWrapper --- packages/sol-compiler/src/utils/fs_wrapper.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'packages/sol-compiler/src/utils') 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.stat), appendFileAsync: promisify(fs.appendFile), accessAsync: promisify(fs.access), + doesFileExistAsync: async (filePath: string): Promise => { + 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; + }, }; -- cgit v1.2.3