common-roots

0.0.2 • Public • Published

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.

npm status node Travis build status AppVeyor build status Dependency status

example

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 do:

npm install common-roots

license

MIT © Vincent Weevers

Readme

Keywords

Package Sidebar

Install

npm i common-roots

Weekly Downloads

217

Version

0.0.2

License

MIT

Unpacked Size

7.78 kB

Total Files

7

Last publish

Collaborators

  • vweevers