https://github.com/vweevers/common-roots
Find root directories (containing .git or other)
https://github.com/vweevers/common-roots
Last synced: about 1 year ago
JSON representation
Find root directories (containing .git or other)
- Host: GitHub
- URL: https://github.com/vweevers/common-roots
- Owner: vweevers
- License: mit
- Created: 2017-06-05T18:49:04.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-08T14:51:21.000Z (almost 5 years ago)
- Last Synced: 2025-03-28T21:39:05.371Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# common-roots
**Given some files, find their root directories (containing some identifying file like `.git`, `package.json`, etc). For files in the same root directory, it does a single lookup.**
[](https://www.npmjs.org/package/common-roots) [](https://www.npmjs.org/package/common-roots) [](http://travis-ci.org/vweevers/common-roots) [](https://ci.appveyor.com/project/vweevers/common-roots) [](https://david-dm.org/vweevers/common-roots)
## example
```js
const roots = require('common-roots')
const files = ['/repo1/a.js', '/repo2/lib', '/repo1/a/b/c']
roots(files, '.git', (err, roots) => {
// roots is ['/repo1', '/repo2']
})
```
## `roots(files, id, done)`
- files: array of files (relative paths are resolved from cwd)
- id: relative path to some file that identifies the root directory
- callback: receives an error (if one of the files has no root directory) or an array of absolute root directories.
## install
With [npm](https://npmjs.org) do:
```
npm install common-roots
```
## license
[MIT](http://opensource.org/licenses/MIT) © Vincent Weevers