Gathering detailed insights and metrics for find-up
Gathering detailed insights and metrics for find-up
Gathering detailed insights and metrics for find-up
Gathering detailed insights and metrics for find-up
Find a file or directory by walking up parent directories
npm install find-up
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.4
Supply Chain
99
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (56.04%)
TypeScript (43.96%)
Total Downloads
25,134,118,021
Last Day
24,672,605
Last Week
112,550,927
Last Month
506,773,670
Last Year
6,543,462,751
589 Stars
70 Commits
41 Forks
11 Watching
1 Branches
15 Contributors
Minified
Minified + Gzipped
Latest Version
7.0.0
Package Id
find-up@7.0.0
Unpacked Size
16.10 kB
Size
3.79 kB
File Count
5
NPM Version
9.2.0
Node Version
18.18.2
Publised On
16 Nov 2023
Cumulative downloads
Total Downloads
Last day
-5%
24,672,605
Compared to previous day
Last week
-15.4%
112,550,927
Compared to previous week
Last month
3.9%
506,773,670
Compared to previous month
Last year
9.9%
6,543,462,751
Compared to previous year
3
5
Find a file or directory by walking up parent directories
1npm install find-up
/
└── Users
└── sindresorhus
├── unicorn.png
└── foo
└── bar
├── baz
└── example.js
example.js
1import path from 'node:path'; 2import {findUp, pathExists} from 'find-up'; 3 4console.log(await findUp('unicorn.png')); 5//=> '/Users/sindresorhus/unicorn.png' 6 7console.log(await findUp(['rainbow.png', 'unicorn.png'])); 8//=> '/Users/sindresorhus/unicorn.png' 9 10console.log(await findUp(async directory => { 11 const hasUnicorns = await pathExists(path.join(directory, 'unicorn.png')); 12 return hasUnicorns && directory; 13}, {type: 'directory'})); 14//=> '/Users/sindresorhus'
Returns a Promise
for either the path or undefined
if it could not 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.
Returns a Promise
for either an array of paths or an empty array if none could be found.
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.
Returns a path or undefined
if it could not be found.
Returns the first path found (by respecting the order of the array) or undefined
if none could be found.
Returns an array of paths or an empty array if none could be found.
Returns an array of the first paths found (by respecting the order of the array) or an empty array if none could be found.
Type: string
The name of the file or directory to find.
Type: Function
A function that will be called with each directory until it returns a string
with the path, which stops the search, or the root directory has been reached and nothing was found. Useful if you want to match files with certain patterns, set of permissions, or other advanced use-cases.
When using async mode, the matcher
may optionally be an async or promise-returning function that returns the path.
Type: object
Type: URL | string
Default: process.cwd()
The directory to start from.
Type: string
Default: 'file'
Values: 'file' | 'directory'
The type of path to match.
Type: boolean
Default: true
Allow symbolic links to match if they point to the chosen path type.
Type: URL | string
Default: Root directory
A directory path where the search halts if no matches are found before reaching this point.
Returns a Promise<boolean>
of whether the path exists.
Returns a boolean
of whether the path exists.
Type: string
The path to a file or directory.
A 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.
1import path from 'node:path'; 2import {findUp, findUpStop} from 'find-up'; 3 4await findUp(directory => { 5 return path.basename(directory) === 'work' ? findUpStop : 'logo.png'; 6});
require.resolve()
but from a given pathNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 10/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Moreread-pkg-up
Read the closest package.json file
pkg-up
Find the closest package.json file
pkg-dir
Find the root directory of a Node.js project or npm package
find-file-up
Find a file fast, by starting at the given cwd and recursing up one directory until the file is found or we run out of directories.