mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-16 08:12:41 +02:00
modified
This commit is contained in:
-24
@@ -1,24 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2013 James Halliday (mail@substack.net)
|
||||
|
||||
Permission is hereby granted, free of charge,
|
||||
to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom
|
||||
the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function (basedir, relfiles) {
|
||||
if (relfiles) {
|
||||
var files = relfiles.map(function (r) {
|
||||
return path.resolve(basedir, r);
|
||||
});
|
||||
}
|
||||
else {
|
||||
var files = basedir;
|
||||
}
|
||||
|
||||
var res = files.slice(1).reduce(function (ps, file) {
|
||||
if (!file.match(/^([A-Za-z]:)?\/|\\/)) {
|
||||
throw new Error('relative path without a basedir');
|
||||
}
|
||||
|
||||
var xs = file.split(/\/+|\\+/);
|
||||
for (
|
||||
var i = 0;
|
||||
ps[i] === xs[i] && i < Math.min(ps.length, xs.length);
|
||||
i++
|
||||
);
|
||||
return ps.slice(0, i);
|
||||
}, files[0].split(/\/+|\\+/));
|
||||
|
||||
// Windows correctly handles paths with forward-slashes
|
||||
return res.length > 1 ? res.join('/') : '/'
|
||||
};
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
{
|
||||
"name": "commondir",
|
||||
"version": "1.0.1",
|
||||
"description": "compute the closest common parent for file paths",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "^3.5.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/substack/node-commondir.git"
|
||||
},
|
||||
"keywords": [
|
||||
"common",
|
||||
"path",
|
||||
"directory",
|
||||
"file",
|
||||
"parent",
|
||||
"root"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engine": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
# commondir
|
||||
|
||||
compute the closest common parent directory among an array of directories
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var commondir = require('commondir');
|
||||
var dir = commondir(process.argv.slice(2))
|
||||
console.log(dir);
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
$ node dir.js /x/y/z /x/y /x/y/w/q
|
||||
/x/y
|
||||
$ node ../baz ../../foo/quux ./bizzy
|
||||
/foo
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
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)`.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install commondir
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user