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