diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index dca35674cd3..2046429b0b3 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -641,6 +641,8 @@ callback, and have some fallback logic if it is null. ## fs.exists(path, callback) +This function is **deprecated**. + Test whether or not the given path exists by checking with the file system. Then call the `callback` argument with either true or false. Example: @@ -658,6 +660,8 @@ and handle the error when it's not there. ## fs.existsSync(path) +This function is **deprecated**. + Synchronous version of `fs.exists`. ## Class: fs.Stats diff --git a/lib/fs.js b/lib/fs.js index 3301a6af847..a57013b20db 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -180,15 +180,15 @@ fs.Stats.prototype.isSocket = function() { return this._checkModeProperty(constants.S_IFSOCK); }; -fs.exists = function(path, callback) { +fs.exists = util.deprecate(function(path, callback) { if (!nullCheck(path, cb)) return; binding.stat(pathModule._makeLong(path), cb); function cb(err, stats) { if (callback) callback(err ? false : true); } -}; +}, 'fs: exists() is deprecated.'); -fs.existsSync = function(path) { +fs.existsSync = util.deprecate(function(path) { try { nullCheck(path); binding.stat(pathModule._makeLong(path)); @@ -196,7 +196,7 @@ fs.existsSync = function(path) { } catch (e) { return false; } -}; +}, 'fs: existsSync() is deprecated.'); fs.readFile = function(path, options, callback_) { var callback = maybeCallback(arguments[arguments.length - 1]); diff --git a/test/common.js b/test/common.js index bd7318c95ef..8ac5a131461 100644 --- a/test/common.js +++ b/test/common.js @@ -37,8 +37,12 @@ if (process.platform === 'win32') { exports.PIPE = exports.tmpDir + '/test.sock'; exports.opensslCli = path.join(process.execPath, '..', 'openssl-cli'); } -if (!fs.existsSync(exports.opensslCli)) + +try { + fs.statSync(exports.opensslCli); +} catch (err) { exports.opensslCli = false; +} if (process.platform === 'win32') { exports.faketimeCli = false;