You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
886 B
Markdown
46 lines
886 B
Markdown
7 years ago
|
commondir
|
||
|
=========
|
||
|
|
||
|
Compute the closest common parent directory among an array of directories.
|
||
|
|
||
|
example
|
||
|
=======
|
||
|
|
||
|
dir
|
||
|
---
|
||
|
|
||
|
> var commondir = require('commondir');
|
||
|
> commondir([ '/x/y/z', '/x/y', '/x/y/w/q' ])
|
||
|
'/x/y'
|
||
|
|
||
|
base
|
||
|
----
|
||
|
|
||
|
> var commondir = require('commondir')
|
||
|
> commondir('/foo/bar', [ '../baz', '../../foo/quux', './bizzy' ])
|
||
|
'/foo'
|
||
|
|
||
|
methods
|
||
|
=======
|
||
|
|
||
|
var commondir = require('commondir');
|
||
|
|
||
|
commondir(absolutePaths)
|
||
|
------------------------
|
||
|
|
||
|
Compute the closest common parent directory for an array `absolutePaths`.
|
||
|
|
||
|
commondir(basedir, relativePaths)
|
||
|
---------------------------------
|
||
|
|
||
|
Compute the closest common parent directory for an array `relativePaths` which
|
||
|
will be resolved for each `dir` in `relativePaths` according to:
|
||
|
`path.resolve(basedir, dir)`.
|
||
|
|
||
|
installation
|
||
|
============
|
||
|
|
||
|
Using [npm](http://npmjs.org), just do:
|
||
|
|
||
|
npm install commondir
|