Implement files.exists in terms of file.statOrNull.

The hitherto-underlying fs.exists function has been deprecated in Node v4.

Part of #6921.
This commit is contained in:
Ben Newman
2016-05-07 13:07:36 -04:00
parent b0144a6260
commit bab72a03d1

View File

@@ -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;