Comparing version 4.1.0 to 5.0.0
139
index.d.ts
@@ -0,1 +1,2 @@ | ||
/* eslint-disable @typescript-eslint/unified-signatures */ | ||
import {Options as LocatePathOptions} from 'locate-path'; | ||
@@ -14,56 +15,19 @@ | ||
declare const findUp: { | ||
/** | ||
Find a file or directory by walking up parent directories. | ||
sync: { | ||
/** | ||
Synchronously check if a path exists. | ||
@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 path - Path to the file or directory. | ||
@returns Whether the path exists. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// ├── unicorn.png | ||
// └── foo | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
@example | ||
``` | ||
import findUp = require('find-up'); | ||
// example.js | ||
import findUp = require('find-up'); | ||
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png')); | ||
//=> true | ||
``` | ||
*/ | ||
exists: (path: string) => boolean; | ||
(async () => { | ||
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>; | ||
/** | ||
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. | ||
@example | ||
``` | ||
import path = require('path'); | ||
import findUp = require('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>; | ||
sync: { | ||
/** | ||
@@ -75,3 +39,3 @@ Synchronously find a file or directory by walking up parent directories. | ||
*/ | ||
(name: string | string[], options?: findUp.Options): string | undefined; | ||
(name: string | readonly string[], options?: findUp.Options): string | undefined; | ||
@@ -97,20 +61,4 @@ /** | ||
(matcher: (directory: string) => findUp.Match, options?: findUp.Options): string | undefined; | ||
}; | ||
/** | ||
Synchronously check if a path exists. | ||
@param path - Path to the file or directory. | ||
@returns Whether the path exists. | ||
@example | ||
``` | ||
import findUp = require('find-up'); | ||
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png')); | ||
//=> true | ||
``` | ||
*/ | ||
exists(path: string): boolean; | ||
} | ||
/** | ||
@@ -132,3 +80,3 @@ Check if a path exists. | ||
*/ | ||
exists(path: string): Promise<boolean>; | ||
exists: (path: string) => Promise<boolean>; | ||
@@ -139,4 +87,57 @@ /** | ||
readonly stop: findUp.StopSymbol; | ||
/** | ||
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. | ||
@example | ||
``` | ||
// / | ||
// └── Users | ||
// └── sindresorhus | ||
// ├── unicorn.png | ||
// └── foo | ||
// └── bar | ||
// ├── baz | ||
// └── example.js | ||
// example.js | ||
import findUp = require('find-up'); | ||
(async () => { | ||
console.log(await findUp('unicorn.png')); | ||
//=> '/Users/sindresorhus/unicorn.png' | ||
console.log(await findUp(['rainbow.png', 'unicorn.png'])); | ||
//=> '/Users/sindresorhus/unicorn.png' | ||
})(); | ||
``` | ||
*/ | ||
(name: string | readonly string[], options?: findUp.Options): Promise<string | undefined>; | ||
/** | ||
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. | ||
@example | ||
``` | ||
import path = require('path'); | ||
import findUp = require('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>; | ||
}; | ||
export = findUp; |
{ | ||
"name": "find-up", | ||
"version": "4.1.0", | ||
"version": "5.0.0", | ||
"description": "Find a file or directory by walking up parent directories", | ||
"license": "MIT", | ||
"repository": "sindresorhus/find-up", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
@@ -43,3 +44,3 @@ "scripts": { | ||
"dependencies": { | ||
"locate-path": "^5.0.0", | ||
"locate-path": "^6.0.0", | ||
"path-exists": "^4.0.0" | ||
@@ -50,6 +51,6 @@ }, | ||
"is-path-inside": "^2.1.0", | ||
"tempy": "^0.3.0", | ||
"tsd": "^0.7.3", | ||
"xo": "^0.24.0" | ||
"tempy": "^0.6.0", | ||
"tsd": "^0.13.1", | ||
"xo": "^0.33.0" | ||
} | ||
} |
@@ -1,6 +0,5 @@ | ||
# 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](https://travis-ci.com/sindresorhus/find-up.svg?branch=master)](https://travis-ci.com/github/sindresorhus/find-up) | ||
> Find a file or directory by walking up parent directories | ||
## Install | ||
@@ -12,3 +11,2 @@ | ||
## Usage | ||
@@ -48,3 +46,2 @@ | ||
## API | ||
@@ -90,3 +87,3 @@ | ||
Type: `string`<br> | ||
Type: `string`\ | ||
Default: `process.cwd()` | ||
@@ -98,4 +95,4 @@ | ||
Type: `string`<br> | ||
Default: `'file'`<br> | ||
Type: `string`\ | ||
Default: `'file'`\ | ||
Values: `'file'` `'directory'` | ||
@@ -107,3 +104,3 @@ | ||
Type: `boolean`<br> | ||
Type: `boolean`\ | ||
Default: `true` | ||
@@ -142,3 +139,2 @@ | ||
## Related | ||
@@ -151,3 +147,2 @@ | ||
--- | ||
@@ -154,0 +149,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
11761
175
152
+ Addedlocate-path@6.0.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
Updatedlocate-path@^6.0.0