Browse Source

Adding path.existsSync (with tests.)

v0.7.4-release
Micheil Smith 15 years ago
committed by Ryan Dahl
parent
commit
b05daaaf69
  1. 9
      lib/path.js
  2. 2
      test/simple/test-path.js

9
lib/path.js

@ -79,3 +79,12 @@ exports.exists = function (path, callback) {
if (callback) callback(err ? false : true);
});
};
exports.existsSync = function (path) {
try {
process.binding('fs').stat(path)
return true;
} catch(e){
return false;
}
};

2
test/simple/test-path.js

@ -12,6 +12,8 @@ assert.equal(path.dirname("/a"), "/");
assert.equal(path.dirname("/"), "/");
path.exists(f, function (y) { assert.equal(y, true) });
assert.equal(path.existsSync(f), true);
assert.equal(path.extname(""), "");
assert.equal(path.extname("/path/to/file"), "");
assert.equal(path.extname("/path/to/file.ext"), ".ext");

Loading…
Cancel
Save