Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bolasblack/find-project-root
recursively find the closest specified file
https://github.com/bolasblack/find-project-root
Last synced: 11 days ago
JSON representation
recursively find the closest specified file
- Host: GitHub
- URL: https://github.com/bolasblack/find-project-root
- Owner: bolasblack
- License: mit
- Created: 2017-05-04T16:19:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-05T02:34:14.000Z (over 7 years ago)
- Last Synced: 2024-11-10T03:36:32.497Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# find-project-root
Recommend use https://github.com/sindresorhus/find-up instead.
Recursively find the closest specified file.
## Usage
```javascript
const assert = require('assert')
const findRoot = require('find-project-root')findRoot('./node_modules/mocha', '.git').then(path => {
assert.equal(path, '')
})
```## findRoot(startingPath, [filename, [cb]])
* `startingPath` `{String}` the starting path to search, default: `module.parent.filename`
* `filename` `{String}` the searching file name, default: `package.json`
* `cb` `{Function}`
* `err` `{Error | null}`
* `path` `{String | null}` the path been found
* return `{Promise}`## findRoot.sync(startingPath, [filename])
* `startingPath` `{String}` the starting path to search, default: `module.parent.filename`
* `filename` `{String}` the searching file name, default: `package.json`
* return `{String | null}` the path been found