0.0.2 • Published 3 years ago

common-roots v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

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