Upgrade Ava to v4
This commit is contained in:
parent
9a40cc5274
commit
ce89f1b611
1153 changed files with 27264 additions and 95308 deletions
321
node_modules/find-up/index.d.ts
generated
vendored
321
node_modules/find-up/index.d.ts
generated
vendored
|
|
@ -1,137 +1,248 @@
|
|||
/* eslint-disable @typescript-eslint/unified-signatures */
|
||||
import {Options as LocatePathOptions} from 'locate-path';
|
||||
|
||||
declare const stop: unique symbol;
|
||||
/**
|
||||
Return this in a `matcher` function to stop the search and force `findUp` to immediately return `undefined`.
|
||||
*/
|
||||
export const findUpStop: unique symbol;
|
||||
|
||||
declare namespace findUp {
|
||||
interface Options extends LocatePathOptions {}
|
||||
export type Match = string | typeof findUpStop | undefined;
|
||||
|
||||
type StopSymbol = typeof stop;
|
||||
export interface Options extends LocatePathOptions {
|
||||
/**
|
||||
The path to the directory to stop the search before reaching root if there were no matches before the `stopAt` directory.
|
||||
|
||||
type Match = string | StopSymbol | undefined;
|
||||
@default path.parse(cwd).root
|
||||
*/
|
||||
readonly stopAt?: string;
|
||||
}
|
||||
|
||||
declare const findUp: {
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
|
||||
@param name - Name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
@param name - The name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
// example.js
|
||||
import findUp = require('find-up');
|
||||
// example.js
|
||||
import {findUp} 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'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(name: string | string[], options?: findUp.Options): Promise<string | undefined>;
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
```
|
||||
*/
|
||||
export function findUp(name: string | readonly string[], options?: Options): Promise<string | undefined>;
|
||||
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUpStop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import path = require('path');
|
||||
import findUp = require('find-up');
|
||||
@example
|
||||
```
|
||||
import path from 'node:path';
|
||||
import {findUp, pathExists} from 'find-up';
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(matcher: (directory: string) => (findUp.Match | Promise<findUp.Match>), options?: findUp.Options): Promise<string | undefined>;
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await pathExists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
```
|
||||
*/
|
||||
export function findUp(matcher: (directory: string) => (Match | Promise<Match>), options?: Options): Promise<string | undefined>;
|
||||
|
||||
sync: {
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
|
||||
@param name - Name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
*/
|
||||
(name: string | string[], options?: findUp.Options): string | undefined;
|
||||
@param name - The name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
// example.js
|
||||
import {findUpSync} from 'find-up';
|
||||
|
||||
@example
|
||||
```
|
||||
import path = require('path');
|
||||
import findUp = require('find-up');
|
||||
console.log(findUpSync('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(findUp.sync(directory => {
|
||||
const hasUnicorns = findUp.sync.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
```
|
||||
*/
|
||||
(matcher: (directory: string) => findUp.Match, options?: findUp.Options): string | undefined;
|
||||
console.log(findUpSync(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
```
|
||||
*/
|
||||
export function findUpSync(name: string | readonly string[], options?: Options): string | undefined;
|
||||
|
||||
/**
|
||||
Synchronously check if a path exists.
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
|
||||
@param path - Path to the file or directory.
|
||||
@returns Whether the path exists.
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUpStop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import findUp = require('find-up');
|
||||
@example
|
||||
```
|
||||
import path from 'node:path';
|
||||
import {findUpSync, pathExistsSync} from 'find-up';
|
||||
|
||||
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
exists(path: string): boolean;
|
||||
}
|
||||
console.log(findUpSync(directory => {
|
||||
const hasUnicorns = pathExistsSync(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
```
|
||||
*/
|
||||
export function findUpSync(matcher: (directory: string) => Match, options?: Options): string | undefined;
|
||||
|
||||
/**
|
||||
Check if a path exists.
|
||||
/**
|
||||
Find files or directories by walking up parent directories.
|
||||
|
||||
@param path - Path to a file or directory.
|
||||
@returns Whether the path exists.
|
||||
@param name - The name of the file or directory to find. Can be multiple.
|
||||
@returns All paths found (by respecting the order of `name`s) or an empty array if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import findUp = require('find-up');
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// ├── unicorn.png
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp.exists('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
})();
|
||||
```
|
||||
*/
|
||||
exists(path: string): Promise<boolean>;
|
||||
// example.js
|
||||
import {findUpMultiple} from 'find-up';
|
||||
|
||||
/**
|
||||
Return this in a `matcher` function to stop the search and force `findUp` to immediately return `undefined`.
|
||||
*/
|
||||
readonly stop: findUp.StopSymbol;
|
||||
};
|
||||
console.log(await findUpMultiple('unicorn.png'));
|
||||
//=> ['/Users/sindresorhus/foo/unicorn.png', '/Users/sindresorhus/unicorn.png']
|
||||
|
||||
export = findUp;
|
||||
console.log(await findUpMultiple(['rainbow.png', 'unicorn.png']));
|
||||
//=> ['/Users/sindresorhus/foo/unicorn.png', '/Users/sindresorhus/unicorn.png']
|
||||
```
|
||||
*/
|
||||
export function findUpMultiple(name: string | readonly string[], options?: Options): Promise<string[]>;
|
||||
|
||||
/**
|
||||
Find files or directories by walking up parent directories.
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUpStop` to stop the search.
|
||||
@returns All paths found or an empty array if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import path from 'node:path';
|
||||
import {findUpMultiple, pathExists} from 'find-up';
|
||||
|
||||
console.log(await findUpMultiple(async directory => {
|
||||
const hasUnicorns = await pathExists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> ['/Users/sindresorhus/foo', '/Users/sindresorhus']
|
||||
```
|
||||
*/
|
||||
export function findUpMultiple(matcher: (directory: string) => (Match | Promise<Match>), options?: Options): Promise<string[]>;
|
||||
|
||||
/**
|
||||
Synchronously find files or directories by walking up parent directories.
|
||||
|
||||
@param name - The name of the file or directory to find. Can be multiple.
|
||||
@returns All paths found (by respecting the order of `name`s) or an empty array if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// ├── unicorn.png
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
// example.js
|
||||
import {findUpMultipleSync} from 'find-up';
|
||||
|
||||
console.log(findUpMultipleSync('unicorn.png'));
|
||||
//=> ['/Users/sindresorhus/foo/unicorn.png', '/Users/sindresorhus/unicorn.png']
|
||||
|
||||
console.log(findUpMultipleSync(['rainbow.png', 'unicorn.png']));
|
||||
//=> ['/Users/sindresorhus/foo/unicorn.png', '/Users/sindresorhus/unicorn.png']
|
||||
```
|
||||
*/
|
||||
export function findUpMultipleSync(name: string | readonly string[], options?: Options): string[];
|
||||
|
||||
/**
|
||||
Synchronously find files or directories by walking up parent directories.
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUpStop` to stop the search.
|
||||
@returns All paths found or an empty array if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import path from 'node:path';
|
||||
import {findUpMultipleSync, pathExistsSync} from 'find-up';
|
||||
|
||||
console.log(findUpMultipleSync(directory => {
|
||||
const hasUnicorns = pathExistsSync(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> ['/Users/sindresorhus/foo', '/Users/sindresorhus']
|
||||
```
|
||||
*/
|
||||
export function findUpMultipleSync(matcher: (directory: string) => Match, options?: Options): string[];
|
||||
|
||||
/**
|
||||
Check if a path exists.
|
||||
|
||||
@param path - The path to a file or directory.
|
||||
@returns Whether the path exists.
|
||||
|
||||
@example
|
||||
```
|
||||
import {pathExists} from 'find-up';
|
||||
|
||||
console.log(await pathExists('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
export function pathExists(path: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
Synchronously check if a path exists.
|
||||
|
||||
@param path - Path to the file or directory.
|
||||
@returns Whether the path exists.
|
||||
|
||||
@example
|
||||
```
|
||||
import {pathExistsSync} from 'find-up';
|
||||
|
||||
console.log(pathExistsSync('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
export function pathExistsSync(path: string): boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue