From bab72a03d1cf43d2deeba464c5ef3ded5ccf3306 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Sat, 7 May 2016 13:07:36 -0400 Subject: [PATCH] Implement files.exists in terms of file.statOrNull. The hitherto-underlying fs.exists function has been deprecated in Node v4. Part of #6921. --- tools/fs/files.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/fs/files.js b/tools/fs/files.js index e3fea8ca88..fb0313c911 100644 --- a/tools/fs/files.js +++ b/tools/fs/files.js @@ -1425,9 +1425,14 @@ wrapFsFunc("readFile", [0], { }); wrapFsFunc("stat", [0]); wrapFsFunc("lstat", [0]); -wrapFsFunc("exists", [0], {noErr: true}); wrapFsFunc("rename", [0, 1]); +// The fs.exists method is deprecated in Node v4: +// https://nodejs.org/api/fs.html#fs_fs_exists_path_callback +files.exists = function (path) { + return !! files.statOrNull(path); +}; + if (process.platform === "win32") { var rename = files.rename;