From 0b912c368a34facea17252d9504c23d98bb48621 Mon Sep 17 00:00:00 2001 From: Liam McLoughlin Date: Fri, 12 Mar 2021 19:33:45 +0000 Subject: [PATCH] Fix bug where fs.exists is incorrectly promisified --- packages/node-resolve/src/fs.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/node-resolve/src/fs.js b/packages/node-resolve/src/fs.js index 11fa93067..71f6c6c9c 100644 --- a/packages/node-resolve/src/fs.js +++ b/packages/node-resolve/src/fs.js @@ -2,8 +2,15 @@ import fs from 'fs'; import { promisify } from 'util'; -export const exists = promisify(fs.exists); export const readFile = promisify(fs.readFile); export const realpath = promisify(fs.realpath); export { realpathSync } from 'fs'; export const stat = promisify(fs.stat); +export async function exists(filePath) { + try { + await stat(filePath); + return true; + } catch { + return false; + } +}