path-exists
Advanced tools
+9
-6
| '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) { |
+7
-3
| { | ||
| "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": "*" | ||
| } | ||
| } |
+6
-21
@@ -25,4 +25,6 @@ # path-exists [](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) |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3470
2.48%20
17.65%1
Infinity%2
100%46
-24.59%+ Added
+ Added
+ Added