You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
780 B

4 years ago
  1. # commondir
  2. compute the closest common parent directory among an array of directories
  3. # example
  4. ``` js
  5. var commondir = require('commondir');
  6. var dir = commondir(process.argv.slice(2))
  7. console.log(dir);
  8. ```
  9. output:
  10. ```
  11. $ node dir.js /x/y/z /x/y /x/y/w/q
  12. /x/y
  13. $ node ../baz ../../foo/quux ./bizzy
  14. /foo
  15. ```
  16. # methods
  17. ``` js
  18. var commondir = require('commondir');
  19. ```
  20. ## commondir(absolutePaths)
  21. Compute the closest common parent directory for an array `absolutePaths`.
  22. ## commondir(basedir, relativePaths)
  23. Compute the closest common parent directory for an array `relativePaths` which
  24. will be resolved for each `dir` in `relativePaths` according to:
  25. `path.resolve(basedir, dir)`.
  26. # install
  27. With [npm](https://npmjs.org) do:
  28. ```
  29. npm install commondir
  30. ```
  31. # license
  32. MIT