@danielbayley/matchup
v1.0.4
Published
Find the first path matching a glob pattern, walking up from a given directory.
Downloads
18
Maintainers
Readme
Matchup
Find the first path matching a glob pattern, walking up from a given directory.
Example
import fs from "node:fs/promises"
import {matchup} from "@danielbayley/matchup"
const cwd = import.meta.dirname
const metadata = await matchup("package.*", { cwd }) // package.json
.then(fs.readFile)
.then(JSON.parse)
.catch(console.error)
console.log(metadata.type) // moduleOptions
| Option | Default | Description |
|:-----------|:------------------------|:------------------------------------------|
| cwd | import.meta.dirname | Search starting point. |
| ignore | ["node_modules"] | ignore paths containing these patterns. |
| parse | | return a node:path object. |
| max | 10 | Maximum upward traversal depth. |
| symlinks | | false will not match symbolic links. |
Install
pnpm install @danielbayley/matchup[!IMPORTANT] This package is ESM only, so must be
imported instead ofrequired, and depends on Node>=20.
Specify this requirement with engines and/or devEngines:
// package.json
"type": "module",
"engines": {
"node": ">=20"
},
"devEngines": {
"runtime": {
"name": "node",
"version": ">=20"
}
},