aboutsummaryrefslogtreecommitdiff
path: root/node_modules/commondir
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-28 00:38:50 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-28 00:40:43 +0200
commit7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 (patch)
tree6de9a1aebd150a23b7f8c273ec657a5d0a18fe3e /node_modules/commondir
parent963b7a41feb29cc4be090a2446bdfe0c1f1bcd81 (diff)
downloadwallet-core-7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027.tar.xz
add linting (and some initial fixes)
Diffstat (limited to 'node_modules/commondir')
-rw-r--r--node_modules/commondir/LICENSE24
-rw-r--r--node_modules/commondir/example/dir.js3
-rw-r--r--node_modules/commondir/index.js29
-rw-r--r--node_modules/commondir/package.json34
-rw-r--r--node_modules/commondir/readme.markdown48
-rw-r--r--node_modules/commondir/test/dirs.js55
6 files changed, 193 insertions, 0 deletions
diff --git a/node_modules/commondir/LICENSE b/node_modules/commondir/LICENSE
new file mode 100644
index 000000000..3d59c7330
--- /dev/null
+++ b/node_modules/commondir/LICENSE
@@ -0,0 +1,24 @@
+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. \ No newline at end of file
diff --git a/node_modules/commondir/example/dir.js b/node_modules/commondir/example/dir.js
new file mode 100644
index 000000000..e86a34648
--- /dev/null
+++ b/node_modules/commondir/example/dir.js
@@ -0,0 +1,3 @@
+var commondir = require('../');
+var dir = commondir(process.argv.slice(2));
+console.log(dir);
diff --git a/node_modules/commondir/index.js b/node_modules/commondir/index.js
new file mode 100644
index 000000000..fa77d0452
--- /dev/null
+++ b/node_modules/commondir/index.js
@@ -0,0 +1,29 @@
+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('/') : '/'
+};
diff --git a/node_modules/commondir/package.json b/node_modules/commondir/package.json
new file mode 100644
index 000000000..7320d956c
--- /dev/null
+++ b/node_modules/commondir/package.json
@@ -0,0 +1,34 @@
+{
+ "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"
+ }
+}
diff --git a/node_modules/commondir/readme.markdown b/node_modules/commondir/readme.markdown
new file mode 100644
index 000000000..6c20607f4
--- /dev/null
+++ b/node_modules/commondir/readme.markdown
@@ -0,0 +1,48 @@
+# 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
diff --git a/node_modules/commondir/test/dirs.js b/node_modules/commondir/test/dirs.js
new file mode 100644
index 000000000..7e55c9bb8
--- /dev/null
+++ b/node_modules/commondir/test/dirs.js
@@ -0,0 +1,55 @@
+var test = require('tape');
+var commondir = require('../');
+
+test('common', function (t) {
+ t.equal(
+ commondir([ '/foo', '//foo/bar', '/foo//bar/baz' ]),
+ '/foo'
+ );
+ t.equal(
+ commondir([ '/a/b/c', '/a/b', '/a/b/c/d/e' ]),
+ '/a/b'
+ );
+ t.equal(
+ commondir([ '/x/y/z/w', '/xy/z', '/x/y/z' ]),
+ '/'
+ );
+ t.equal(
+ commondir([ 'X:\\foo', 'X:\\\\foo\\bar', 'X://foo/bar/baz' ]),
+ 'X:/foo'
+ );
+ t.equal(
+ commondir([ 'X:\\a\\b\\c', 'X:\\a\\b', 'X:\\a\\b\\c\\d\\e' ]),
+ 'X:/a/b'
+ );
+ t.equal(
+ commondir([ 'X:\\x\\y\\z\\w', '\\\\xy\\z', '\\x\\y\\z' ]),
+ '/'
+ );
+ t.throws(function () {
+ commondir([ '/x/y/z/w', 'qrs', '/x/y/z' ]);
+ });
+ t.end();
+});
+
+test('base', function (t) {
+ t.equal(
+ commondir('/foo/bar', [ 'baz', './quux', '../bar/bazzy' ]),
+ '/foo/bar'
+ );
+ t.equal(
+ commondir('/a/b', [ 'c', '../b/.', '../../a/b/e' ]),
+ '/a/b'
+ );
+ t.equal(
+ commondir('/a/b/c', [ '..', '../d', '../../a/z/e' ]),
+ '/a'
+ );
+ t.equal(
+ commondir('/foo/bar', [ 'baz', '.\\quux', '..\\bar\\bazzy' ]),
+ '/foo/bar'
+ );
+ // Tests including X:\ basedirs must wait until path.resolve supports
+ // Windows-style paths, starting in Node.js v0.5.X
+ t.end();
+});