diff --git a/package.json b/package.json index 19e9888..1d3cd13 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@types/jest": "^27.0.3", "@types/minimist": "^1.2.2", - "@types/node": "^6.0.54", + "@types/node": "^12.0.0", "@types/strip-bom": "^3.0.0", "@types/strip-json-comments": "^0.0.30", "@typescript-eslint/eslint-plugin": "^5.22.0", diff --git a/src/filesystem.ts b/src/filesystem.ts index d4f60b4..04cbdbb 100644 --- a/src/filesystem.ts +++ b/src/filesystem.ts @@ -34,16 +34,8 @@ export interface ReadJsonAsync { export function fileExistsSync(path: string): boolean { // If the file doesn't exist, avoid throwing an exception over the native barrier for every miss - if (!fs.existsSync(path)) { - return false; - } - try { - const stats = fs.statSync(path); - return stats.isFile(); - } catch (err) { - // If error, assume file did not exist - return false; - } + // @ts-expect-error throwIfNoEntry is a noop pre node 14.7, but is not part of the types + return !!fs.statSync(path, { throwIfNoEntry: false })?.isFile(); } /** diff --git a/yarn.lock b/yarn.lock index 84945cb..d8772c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -710,9 +710,10 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.9.tgz#879be3ad7af29f4c1a5c433421bf99fab7047185" integrity sha512-MKmdASMf3LtPzwLyRrFjtFFZ48cMf8jmX5VRYrDQiJa8Ybu5VAmkqBWqKU8fdCwD8ysw4mQ9nrEHvzg6gunR7A== -"@types/node@^6.0.54": - version "6.0.54" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.54.tgz#65859962ba988052cbdd5c48881395acfdd46931" +"@types/node@^12.0.0": + version "12.20.55" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" + integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== "@types/parse-json@^4.0.0": version "4.0.0"