path-exists
Advanced tools
Comparing version 2.1.0 to 3.0.0
21
index.js
'use strict'; | ||
var fs = require('fs'); | ||
var Promise = require('pinkie-promise'); | ||
const fs = require('fs'); | ||
module.exports = function (fp) { | ||
var fn = typeof fs.access === 'function' ? fs.access : fs.stat; | ||
return new Promise(function (resolve) { | ||
fn(fp, function (err) { | ||
resolve(!err); | ||
}); | ||
module.exports = fp => new Promise(resolve => { | ||
fs.access(fp, err => { | ||
resolve(!err); | ||
}); | ||
}; | ||
}); | ||
module.exports.sync = function (fp) { | ||
var fn = typeof fs.accessSync === 'function' ? fs.accessSync : fs.statSync; | ||
module.exports.sync = fp => { | ||
try { | ||
fn(fp); | ||
fs.accessSync(fp); | ||
return true; | ||
@@ -21,0 +14,0 @@ } catch (err) { |
{ | ||
"name": "path-exists", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Check if a path exists", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
@@ -34,9 +34,9 @@ "scripts": { | ||
], | ||
"dependencies": { | ||
"pinkie-promise": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
@@ -23,5 +23,5 @@ # path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists) | ||
// foo.js | ||
var pathExists = require('path-exists'); | ||
const pathExists = require('path-exists'); | ||
pathExists('foo.js').then(function (exists) { | ||
pathExists('foo.js').then(exists => { | ||
console.log(exists); | ||
@@ -37,3 +37,3 @@ //=> true | ||
Returns a promise that resolves to a boolean of whether the path exists. | ||
Returns a promise for a boolean of whether the path exists. | ||
@@ -45,4 +45,9 @@ ### pathExists.sync(path) | ||
## Related | ||
- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
0
51
3316
15
- Removedpinkie-promise@^2.0.0
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)