Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
94
node_modules/find-up/readme.md
generated
vendored
94
node_modules/find-up/readme.md
generated
vendored
|
|
@ -1,15 +1,13 @@
|
|||
# find-up [](https://travis-ci.org/sindresorhus/find-up)
|
||||
# find-up
|
||||
|
||||
> Find a file or directory by walking up parent directories
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install find-up
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
|
|
@ -26,25 +24,22 @@ $ npm install find-up
|
|||
`example.js`
|
||||
|
||||
```js
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
import path from 'node:path';
|
||||
import {findUp, pathExists} from 'find-up';
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
console.log(await findUp('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
})();
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await pathExists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### findUp(name, options?)
|
||||
|
|
@ -56,20 +51,38 @@ Returns a `Promise` for either the path or `undefined` if it couldn't be found.
|
|||
|
||||
Returns a `Promise` for either the first path found (by respecting the order of the array) or `undefined` if none could be found.
|
||||
|
||||
### findUp.sync(name, options?)
|
||||
### findUp.sync(matcher, options?)
|
||||
### findUpMultiple(name, options?)
|
||||
### findUpMultiple(matcher, options?)
|
||||
|
||||
Returns a `Promise` for either an array of paths or an empty array if none could be found.
|
||||
|
||||
### findUpMultiple([...name], options?)
|
||||
|
||||
Returns a `Promise` for either an array of the first paths found (by respecting the order of the array) or an empty array if none could be found.
|
||||
|
||||
### findUpSync(name, options?)
|
||||
### findUpSync(matcher, options?)
|
||||
|
||||
Returns a path or `undefined` if it couldn't be found.
|
||||
|
||||
### findUp.sync([...name], options?)
|
||||
### findUpSync([...name], options?)
|
||||
|
||||
Returns the first path found (by respecting the order of the array) or `undefined` if none could be found.
|
||||
|
||||
### findUpMultipleSync(name, options?)
|
||||
### findUpMultipleSync(matcher, options?)
|
||||
|
||||
Returns an array of paths or an empty array if none could be found.
|
||||
|
||||
### findUpMultipleSync([...name], options?)
|
||||
|
||||
Returns an array of the first paths found (by respecting the order of the array) or an empty array if none could be found.
|
||||
|
||||
#### name
|
||||
|
||||
Type: `string`
|
||||
|
||||
Name of the file or directory to find.
|
||||
The name of the file or directory to find.
|
||||
|
||||
#### matcher
|
||||
|
||||
|
|
@ -85,31 +98,38 @@ Type: `object`
|
|||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Type: `string`\
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
The directory to start from.
|
||||
|
||||
##### type
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'file'`<br>
|
||||
Type: `string`\
|
||||
Default: `'file'`\
|
||||
Values: `'file'` `'directory'`
|
||||
|
||||
The type of paths that can match.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Type: `boolean`<br>
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Allow symbolic links to match if they point to the chosen path type.
|
||||
|
||||
### findUp.exists(path)
|
||||
##### stopAt
|
||||
|
||||
Type: `string`\
|
||||
Default: `path.parse(cwd).root`
|
||||
|
||||
The path to the directory to stop the search before reaching root if there were no matches before the `stopAt` directory.
|
||||
|
||||
### pathExists(path)
|
||||
|
||||
Returns a `Promise<boolean>` of whether the path exists.
|
||||
|
||||
### findUp.sync.exists(path)
|
||||
### pathExistsSync(path)
|
||||
|
||||
Returns a `boolean` of whether the path exists.
|
||||
|
||||
|
|
@ -117,24 +137,21 @@ Returns a `boolean` of whether the path exists.
|
|||
|
||||
Type: `string`
|
||||
|
||||
Path to a file or directory.
|
||||
The path to a file or directory.
|
||||
|
||||
### findUp.stop
|
||||
### findUpStop
|
||||
|
||||
A [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that can be returned by a `matcher` function to stop the search and cause `findUp` to immediately return `undefined`. Useful as a performance optimization in case the current working directory is deeply nested in the filesystem.
|
||||
|
||||
```js
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
import path from 'node:path';
|
||||
import {findUp, findUpStop} from 'find-up';
|
||||
|
||||
(async () => {
|
||||
await findUp(directory => {
|
||||
return path.basename(directory) === 'work' ? findUp.stop : 'logo.png';
|
||||
});
|
||||
})();
|
||||
await findUp(directory => {
|
||||
return path.basename(directory) === 'work' ? findUpStop : 'logo.png';
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
|
||||
|
|
@ -142,7 +159,6 @@ const findUp = require('find-up');
|
|||
- [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
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue