locate-path
Advanced tools
Comparing version 2.0.0 to 3.0.0
16
index.js
@@ -6,17 +6,17 @@ 'use strict'; | ||
module.exports = (iterable, opts) => { | ||
opts = Object.assign({ | ||
module.exports = (iterable, options) => { | ||
options = Object.assign({ | ||
cwd: process.cwd() | ||
}, opts); | ||
}, options); | ||
return pLocate(iterable, el => pathExists(path.resolve(opts.cwd, el)), opts); | ||
return pLocate(iterable, el => pathExists(path.resolve(options.cwd, el)), options); | ||
}; | ||
module.exports.sync = (iterable, opts) => { | ||
opts = Object.assign({ | ||
module.exports.sync = (iterable, options) => { | ||
options = Object.assign({ | ||
cwd: process.cwd() | ||
}, opts); | ||
}, options); | ||
for (const el of iterable) { | ||
if (pathExists.sync(path.resolve(opts.cwd, el))) { | ||
if (pathExists.sync(path.resolve(options.cwd, el))) { | ||
return el; | ||
@@ -23,0 +23,0 @@ } |
{ | ||
"name": "locate-path", | ||
"version": "2.0.0", | ||
"description": "Get the first path that exists on disk of multiple paths", | ||
"license": "MIT", | ||
"repository": "sindresorhus/locate-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"locate", | ||
"path", | ||
"paths", | ||
"file", | ||
"files", | ||
"exists", | ||
"find", | ||
"finder", | ||
"search", | ||
"searcher", | ||
"array", | ||
"iterable", | ||
"iterator" | ||
], | ||
"dependencies": { | ||
"p-locate": "^2.0.0", | ||
"path-exists": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "locate-path", | ||
"version": "3.0.0", | ||
"description": "Get the first path that exists on disk of multiple paths", | ||
"license": "MIT", | ||
"repository": "sindresorhus/locate-path", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"locate", | ||
"path", | ||
"paths", | ||
"file", | ||
"files", | ||
"exists", | ||
"find", | ||
"finder", | ||
"search", | ||
"searcher", | ||
"array", | ||
"iterable", | ||
"iterator" | ||
], | ||
"dependencies": { | ||
"p-locate": "^3.0.0", | ||
"path-exists": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # locate-path [![Build Status](https://travis-ci.org/sindresorhus/locate-path.svg?branch=master)](https://travis-ci.org/sindresorhus/locate-path) | ||
``` | ||
$ npm install --save locate-path | ||
$ npm install locate-path | ||
``` | ||
@@ -23,10 +23,10 @@ | ||
'unicorn.png', | ||
'rainbow.png', // only this one actually exists on disk | ||
'rainbow.png', // Only this one actually exists on disk | ||
'pony.png' | ||
]; | ||
locatePath(files).then(foundPath => { | ||
console.log(foundPath); | ||
(async () => { | ||
console(await locatePath(files)); | ||
//=> 'rainbow' | ||
}); | ||
})(); | ||
``` | ||
@@ -33,0 +33,0 @@ |
Sorry, the diff of this file is not supported yet
3869
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
Updatedp-locate@^3.0.0