Comparing version 2.1.0 to 3.0.0
16
index.js
@@ -5,7 +5,5 @@ 'use strict'; | ||
module.exports = (filename, opts) => { | ||
opts = opts || {}; | ||
module.exports = (filename, opts = {}) => { | ||
const startDir = path.resolve(opts.cwd || ''); | ||
const root = path.parse(startDir).root; | ||
const {root} = path.parse(startDir); | ||
@@ -29,7 +27,5 @@ const filenames = [].concat(filename); | ||
module.exports.sync = (filename, opts) => { | ||
opts = opts || {}; | ||
module.exports.sync = (filename, opts = {}) => { | ||
let dir = path.resolve(opts.cwd || ''); | ||
const root = path.parse(dir).root; | ||
const {root} = path.parse(dir); | ||
@@ -44,3 +40,5 @@ const filenames = [].concat(filename); | ||
return path.join(dir, file); | ||
} else if (dir === root) { | ||
} | ||
if (dir === root) { | ||
return null; | ||
@@ -47,0 +45,0 @@ } |
{ | ||
"name": "find-up", | ||
"version": "2.1.0", | ||
"description": "Find a file by walking up parent directories", | ||
"license": "MIT", | ||
"repository": "sindresorhus/find-up", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"find", | ||
"up", | ||
"find-up", | ||
"findup", | ||
"look-up", | ||
"look", | ||
"file", | ||
"search", | ||
"match", | ||
"package", | ||
"resolve", | ||
"parent", | ||
"parents", | ||
"folder", | ||
"directory", | ||
"dir", | ||
"walk", | ||
"walking", | ||
"path" | ||
], | ||
"dependencies": { | ||
"locate-path": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"tempfile": "^1.1.1", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "find-up", | ||
"version": "3.0.0", | ||
"description": "Find a file or directory by walking up parent directories", | ||
"license": "MIT", | ||
"repository": "sindresorhus/find-up", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"find", | ||
"up", | ||
"find-up", | ||
"findup", | ||
"look-up", | ||
"look", | ||
"file", | ||
"search", | ||
"match", | ||
"package", | ||
"resolve", | ||
"parent", | ||
"parents", | ||
"folder", | ||
"directory", | ||
"dir", | ||
"walk", | ||
"walking", | ||
"path" | ||
], | ||
"dependencies": { | ||
"locate-path": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"tempy": "^0.2.1", | ||
"xo": "*" | ||
} | ||
} |
# find-up [![Build Status: Linux and macOS](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/l0cyjmvh5lq72vq2/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/find-up/branch/master) | ||
> Find a file by walking up parent directories | ||
> Find a file or directory by walking up parent directories | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save find-up | ||
$ npm install find-up | ||
``` | ||
@@ -27,15 +27,14 @@ | ||
`example.js` | ||
```js | ||
// example.js | ||
const findUp = require('find-up'); | ||
findUp('unicorn.png').then(filepath => { | ||
console.log(filepath); | ||
(async () => { | ||
console.log(await findUp('unicorn.png')); | ||
//=> '/Users/sindresorhus/unicorn.png' | ||
}); | ||
findUp(['rainbow.png', 'unicorn.png']).then(filepath => { | ||
console.log(filepath); | ||
console.log(await findUp(['rainbow.png', 'unicorn.png'])); | ||
//=> '/Users/sindresorhus/unicorn.png' | ||
}); | ||
})(); | ||
``` | ||
@@ -48,7 +47,7 @@ | ||
Returns a `Promise` for the filepath or `null`. | ||
Returns a `Promise` for either the filepath or `null` if it couldn't be found. | ||
### findUp([filenameA, filenameB], [options]) | ||
Returns a `Promise` for the first filepath found (by respecting the order) or `null`. | ||
Returns a `Promise` for either the first filepath found (by respecting the order) or `null` if none could be found. | ||
@@ -71,2 +70,4 @@ ### findUp.sync(filename, [options]) | ||
Type: `Object` | ||
##### cwd | ||
@@ -85,2 +86,3 @@ | ||
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package | ||
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module like `require.resolve()` but from a given path | ||
@@ -87,0 +89,0 @@ |
Sorry, the diff of this file is not supported yet
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
4845
88
37
+ Addedlocate-path@3.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
Updatedlocate-path@^3.0.0