locate-path
Advanced tools
Comparing version 1.0.0 to 1.1.0
21
index.js
'use strict'; | ||
const path = require('path'); | ||
const pathExists = require('path-exists'); | ||
const pLocate = require('p-locate'); | ||
module.exports = (iterable, opts) => pLocate(iterable, el => pathExists(el), opts); | ||
module.exports = (iterable, opts) => { | ||
opts = Object.assign({ | ||
cwd: process.cwd() | ||
}, opts); | ||
module.exports.sync = iterable => { | ||
for (const x of iterable) { | ||
if (pathExists.sync(x)) { | ||
return x; | ||
return pLocate(iterable, el => pathExists(path.resolve(opts.cwd, el)), opts); | ||
}; | ||
module.exports.sync = (iterable, opts) => { | ||
opts = Object.assign({ | ||
cwd: process.cwd() | ||
}, opts); | ||
for (const el of iterable) { | ||
if (pathExists.sync(path.resolve(opts.cwd, el))) { | ||
return el; | ||
} | ||
} | ||
}; |
{ | ||
"name": "locate-path", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Get the first path that exists on disk of multiple paths", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -59,4 +59,11 @@ # locate-path [![Build Status](https://travis-ci.org/sindresorhus/locate-path.svg?branch=master)](https://travis-ci.org/sindresorhus/locate-path) | ||
### locatePath.sync(input) | ||
##### cwd | ||
Type: `string`<br> | ||
Default: `process.cwd()` | ||
Current working directory. | ||
### locatePath.sync(input, [options]) | ||
Returns the first path that exists or `undefined` if none exists. | ||
@@ -70,3 +77,11 @@ | ||
#### options | ||
Type: `Object` | ||
##### cwd | ||
Same as above. | ||
## Related | ||
@@ -73,0 +88,0 @@ |
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
3871
20
93