aboutsummaryrefslogtreecommitdiff
path: root/node_modules/find-up
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/find-up
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
downloadwallet-core-363723fc84f7b8477592e0105aeb331ec9a017af.tar.xz
node_modules
Diffstat (limited to 'node_modules/find-up')
-rw-r--r--node_modules/find-up/index.js61
-rw-r--r--node_modules/find-up/package.json10
-rw-r--r--node_modules/find-up/readme.md33
3 files changed, 57 insertions, 47 deletions
diff --git a/node_modules/find-up/index.js b/node_modules/find-up/index.js
index 7ff0e2b78..939c9553d 100644
--- a/node_modules/find-up/index.js
+++ b/node_modules/find-up/index.js
@@ -1,53 +1,48 @@
'use strict';
-var path = require('path');
-var pathExists = require('path-exists');
-var Promise = require('pinkie-promise');
+const path = require('path');
+const locatePath = require('locate-path');
-function splitPath(x) {
- return path.resolve(x || '').split(path.sep);
-}
-
-function join(parts, filename) {
- return path.resolve(parts.join(path.sep) + path.sep, filename);
-}
-
-module.exports = function (filename, opts) {
+module.exports = (filename, opts) => {
opts = opts || {};
- var parts = splitPath(opts.cwd);
+ const startDir = path.resolve(opts.cwd || '');
+ const root = path.parse(startDir).root;
- return new Promise(function (resolve) {
- (function find() {
- var fp = join(parts, filename);
+ const filenames = [].concat(filename);
- pathExists(fp).then(function (exists) {
- if (exists) {
- resolve(fp);
- } else if (parts.pop()) {
- find();
- } else {
+ return new Promise(resolve => {
+ (function find(dir) {
+ locatePath(filenames, {cwd: dir}).then(file => {
+ if (file) {
+ resolve(path.join(dir, file));
+ } else if (dir === root) {
resolve(null);
+ } else {
+ find(path.dirname(dir));
}
});
- })();
+ })(startDir);
});
};
-module.exports.sync = function (filename, opts) {
+module.exports.sync = (filename, opts) => {
opts = opts || {};
- var parts = splitPath(opts.cwd);
- var len = parts.length;
+ let dir = path.resolve(opts.cwd || '');
+ const root = path.parse(dir).root;
+
+ const filenames = [].concat(filename);
- while (len--) {
- var fp = join(parts, filename);
+ // eslint-disable-next-line no-constant-condition
+ while (true) {
+ const file = locatePath.sync(filenames, {cwd: dir});
- if (pathExists.sync(fp)) {
- return fp;
+ if (file) {
+ return path.join(dir, file);
+ } else if (dir === root) {
+ return null;
}
- parts.pop();
+ dir = path.dirname(dir);
}
-
- return null;
};
diff --git a/node_modules/find-up/package.json b/node_modules/find-up/package.json
index 478866c49..7ec85bb79 100644
--- a/node_modules/find-up/package.json
+++ b/node_modules/find-up/package.json
@@ -1,6 +1,6 @@
{
"name": "find-up",
- "version": "1.1.2",
+ "version": "2.1.0",
"description": "Find a file by walking up parent directories",
"license": "MIT",
"repository": "sindresorhus/find-up",
@@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
- "node": ">=0.10.0"
+ "node": ">=4"
},
"scripts": {
"test": "xo && ava"
@@ -40,12 +40,14 @@
"path"
],
"dependencies": {
- "path-exists": "^2.0.0",
- "pinkie-promise": "^2.0.0"
+ "locate-path": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"tempfile": "^1.1.1",
"xo": "*"
+ },
+ "xo": {
+ "esnext": true
}
}
diff --git a/node_modules/find-up/readme.md b/node_modules/find-up/readme.md
index 9ea0611c3..b5ad69455 100644
--- a/node_modules/find-up/readme.md
+++ b/node_modules/find-up/readme.md
@@ -1,4 +1,4 @@
-# find-up [![Build Status](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up)
+# 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
@@ -15,12 +15,12 @@ $ npm install --save find-up
```
/
└── Users
- └── sindresorhus
- ├── unicorn.png
- └── foo
- └── bar
- ├── baz
- └── example.js
+ └── sindresorhus
+ ├── unicorn.png
+ └── foo
+ └── bar
+ ├── baz
+ └── example.js
```
```js
@@ -31,6 +31,11 @@ findUp('unicorn.png').then(filepath => {
console.log(filepath);
//=> '/Users/sindresorhus/unicorn.png'
});
+
+findUp(['rainbow.png', 'unicorn.png']).then(filepath => {
+ console.log(filepath);
+ //=> '/Users/sindresorhus/unicorn.png'
+});
```
@@ -38,12 +43,20 @@ findUp('unicorn.png').then(filepath => {
### findUp(filename, [options])
-Returns a promise for the filepath or `null`.
+Returns a `Promise` for the filepath or `null`.
+
+### findUp([filenameA, filenameB], [options])
+
+Returns a `Promise` for the first filepath found (by respecting the order) or `null`.
### findUp.sync(filename, [options])
Returns a filepath or `null`.
+### findUp.sync([filenameA, filenameB], [options])
+
+Returns the first filepath found (by respecting the order) or `null`.
+
#### filename
Type: `string`
@@ -54,7 +67,7 @@ Filename of the file to find.
##### cwd
-Type: `string`
+Type: `string`<br>
Default: `process.cwd()`
Directory to start from.
@@ -69,4 +82,4 @@ Directory to start from.
## License
-MIT © [Sindre Sorhus](http://sindresorhus.com)
+MIT © [Sindre Sorhus](https://sindresorhus.com)