path-exists
Advanced tools
Comparing version 1.0.0 to 2.0.0
15
index.js
'use strict'; | ||
var fs = require('fs') | ||
var fs = require('fs'); | ||
var Promise = require('pinkie-promise'); | ||
module.exports = function (pth, cb) { | ||
module.exports = function (fp) { | ||
var fn = typeof fs.access === 'function' ? fs.access : fs.stat; | ||
fn(pth, function (err) { | ||
cb(null, !err); | ||
return new Promise(function (resolve) { | ||
fn(fp, function (err) { | ||
resolve(!err); | ||
}); | ||
}); | ||
}; | ||
module.exports.sync = function (pth) { | ||
module.exports.sync = function (fp) { | ||
var fn = typeof fs.accessSync === 'function' ? fs.accessSync : fs.statSync; | ||
try { | ||
fn(pth); | ||
fn(fp); | ||
return true; | ||
@@ -18,0 +21,0 @@ } catch (err) { |
{ | ||
"name": "path-exists", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Check if a path exists", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -34,5 +34,9 @@ "files": [ | ||
], | ||
"dependencies": { | ||
"pinkie-promise": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.0.4" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -25,4 +25,6 @@ # path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists) | ||
pathExists.sync('foo.js'); | ||
//=> true | ||
pathExists('foo.js').then(function (exists) { | ||
console.log(exists); | ||
//=> true | ||
}); | ||
``` | ||
@@ -33,18 +35,6 @@ | ||
### pathExists(path, callback) | ||
### pathExists(path) | ||
#### path | ||
Returns a promise that resolves to a boolean of whether the path exists. | ||
*Required* | ||
Type: `string` | ||
#### callback(error, exists) | ||
*Required* | ||
Type: `function` | ||
##### exists | ||
Type: `boolean` | ||
### pathExists.sync(path) | ||
@@ -54,10 +44,5 @@ | ||
#### path | ||
*Required* | ||
Type: `string` | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3470
20
1
2
46
+ Addedpinkie-promise@^1.0.0
+ Addedpinkie@1.0.0(transitive)
+ Addedpinkie-promise@1.0.0(transitive)