first commit
This commit is contained in:
2
build/node_modules/path-posix/.npmignore
generated
vendored
Normal file
2
build/node_modules/path-posix/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
24
build/node_modules/path-posix/LICENSE.md
generated
vendored
Normal file
24
build/node_modules/path-posix/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
Node's license follows:
|
||||
|
||||
====
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
|
||||
====
|
||||
30
build/node_modules/path-posix/README.md
generated
vendored
Normal file
30
build/node_modules/path-posix/README.md
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# path-posix
|
||||
posix-specific core path module
|
||||
|
||||
## usage
|
||||
```js
|
||||
var path = require('path-posix')
|
||||
path.resolve(__dirname, 'foo')
|
||||
```
|
||||
|
||||
Extracted from lib/path.js in joyent/node@31d4847d8b18cf487775dee3471dd4653b7d860b (master as of 2015/01/26)
|
||||
|
||||
## api
|
||||
see [http://nodejs.org/api/path.html#path_path_resolve_from_to](http://nodejs.org/api/path.html#path_path_resolve_from_to)
|
||||
|
||||
## installation
|
||||
|
||||
$ npm install path-posix
|
||||
|
||||
|
||||
## running the tests
|
||||
|
||||
From package root:
|
||||
|
||||
$ npm install
|
||||
$ npm test
|
||||
|
||||
|
||||
## license
|
||||
|
||||
See LICENSE.md
|
||||
274
build/node_modules/path-posix/index.js
generated
vendored
Normal file
274
build/node_modules/path-posix/index.js
generated
vendored
Normal file
@@ -0,0 +1,274 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
var util = require('util');
|
||||
var isString = function (x) {
|
||||
return typeof x === 'string';
|
||||
};
|
||||
|
||||
|
||||
// resolves . and .. elements in a path array with directory names there
|
||||
// must be no slashes or device names (c:\) in the array
|
||||
// (so also no leading and trailing slashes - it does not distinguish
|
||||
// relative and absolute paths)
|
||||
function normalizeArray(parts, allowAboveRoot) {
|
||||
var res = [];
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var p = parts[i];
|
||||
|
||||
// ignore empty parts
|
||||
if (!p || p === '.')
|
||||
continue;
|
||||
|
||||
if (p === '..') {
|
||||
if (res.length && res[res.length - 1] !== '..') {
|
||||
res.pop();
|
||||
} else if (allowAboveRoot) {
|
||||
res.push('..');
|
||||
}
|
||||
} else {
|
||||
res.push(p);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// Split a filename into [root, dir, basename, ext], unix version
|
||||
// 'root' is just a slash, or nothing.
|
||||
var splitPathRe =
|
||||
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
||||
var posix = {};
|
||||
|
||||
|
||||
function posixSplitPath(filename) {
|
||||
return splitPathRe.exec(filename).slice(1);
|
||||
}
|
||||
|
||||
|
||||
// path.resolve([from ...], to)
|
||||
// posix version
|
||||
posix.resolve = function() {
|
||||
var resolvedPath = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
var path = (i >= 0) ? arguments[i] : process.cwd();
|
||||
|
||||
// Skip empty and invalid entries
|
||||
if (!isString(path)) {
|
||||
throw new TypeError('Arguments to path.resolve must be strings');
|
||||
} else if (!path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resolvedPath = path + '/' + resolvedPath;
|
||||
resolvedAbsolute = path.charAt(0) === '/';
|
||||
}
|
||||
|
||||
// At this point the path should be resolved to a full absolute path, but
|
||||
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||
|
||||
// Normalize the path
|
||||
resolvedPath = normalizeArray(resolvedPath.split('/'),
|
||||
!resolvedAbsolute).join('/');
|
||||
|
||||
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||
};
|
||||
|
||||
// path.normalize(path)
|
||||
// posix version
|
||||
posix.normalize = function(path) {
|
||||
var isAbsolute = posix.isAbsolute(path),
|
||||
trailingSlash = path.substr(-1) === '/';
|
||||
|
||||
// Normalize the path
|
||||
path = normalizeArray(path.split('/'), !isAbsolute).join('/');
|
||||
|
||||
if (!path && !isAbsolute) {
|
||||
path = '.';
|
||||
}
|
||||
if (path && trailingSlash) {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
return (isAbsolute ? '/' : '') + path;
|
||||
};
|
||||
|
||||
// posix version
|
||||
posix.isAbsolute = function(path) {
|
||||
return path.charAt(0) === '/';
|
||||
};
|
||||
|
||||
// posix version
|
||||
posix.join = function() {
|
||||
var path = '';
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var segment = arguments[i];
|
||||
if (!isString(segment)) {
|
||||
throw new TypeError('Arguments to path.join must be strings');
|
||||
}
|
||||
if (segment) {
|
||||
if (!path) {
|
||||
path += segment;
|
||||
} else {
|
||||
path += '/' + segment;
|
||||
}
|
||||
}
|
||||
}
|
||||
return posix.normalize(path);
|
||||
};
|
||||
|
||||
|
||||
// path.relative(from, to)
|
||||
// posix version
|
||||
posix.relative = function(from, to) {
|
||||
from = posix.resolve(from).substr(1);
|
||||
to = posix.resolve(to).substr(1);
|
||||
|
||||
function trim(arr) {
|
||||
var start = 0;
|
||||
for (; start < arr.length; start++) {
|
||||
if (arr[start] !== '') break;
|
||||
}
|
||||
|
||||
var end = arr.length - 1;
|
||||
for (; end >= 0; end--) {
|
||||
if (arr[end] !== '') break;
|
||||
}
|
||||
|
||||
if (start > end) return [];
|
||||
return arr.slice(start, end + 1);
|
||||
}
|
||||
|
||||
var fromParts = trim(from.split('/'));
|
||||
var toParts = trim(to.split('/'));
|
||||
|
||||
var length = Math.min(fromParts.length, toParts.length);
|
||||
var samePartsLength = length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (fromParts[i] !== toParts[i]) {
|
||||
samePartsLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var outputParts = [];
|
||||
for (var i = samePartsLength; i < fromParts.length; i++) {
|
||||
outputParts.push('..');
|
||||
}
|
||||
|
||||
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
||||
|
||||
return outputParts.join('/');
|
||||
};
|
||||
|
||||
|
||||
posix._makeLong = function(path) {
|
||||
return path;
|
||||
};
|
||||
|
||||
|
||||
posix.dirname = function(path) {
|
||||
var result = posixSplitPath(path),
|
||||
root = result[0],
|
||||
dir = result[1];
|
||||
|
||||
if (!root && !dir) {
|
||||
// No dirname whatsoever
|
||||
return '.';
|
||||
}
|
||||
|
||||
if (dir) {
|
||||
// It has a dirname, strip trailing slash
|
||||
dir = dir.substr(0, dir.length - 1);
|
||||
}
|
||||
|
||||
return root + dir;
|
||||
};
|
||||
|
||||
|
||||
posix.basename = function(path, ext) {
|
||||
var f = posixSplitPath(path)[2];
|
||||
// TODO: make this comparison case-insensitive on windows?
|
||||
if (ext && f.substr(-1 * ext.length) === ext) {
|
||||
f = f.substr(0, f.length - ext.length);
|
||||
}
|
||||
return f;
|
||||
};
|
||||
|
||||
|
||||
posix.extname = function(path) {
|
||||
return posixSplitPath(path)[3];
|
||||
};
|
||||
|
||||
|
||||
posix.format = function(pathObject) {
|
||||
if (!util.isObject(pathObject)) {
|
||||
throw new TypeError(
|
||||
"Parameter 'pathObject' must be an object, not " + typeof pathObject
|
||||
);
|
||||
}
|
||||
|
||||
var root = pathObject.root || '';
|
||||
|
||||
if (!isString(root)) {
|
||||
throw new TypeError(
|
||||
"'pathObject.root' must be a string or undefined, not " +
|
||||
typeof pathObject.root
|
||||
);
|
||||
}
|
||||
|
||||
var dir = pathObject.dir ? pathObject.dir + posix.sep : '';
|
||||
var base = pathObject.base || '';
|
||||
return dir + base;
|
||||
};
|
||||
|
||||
|
||||
posix.parse = function(pathString) {
|
||||
if (!isString(pathString)) {
|
||||
throw new TypeError(
|
||||
"Parameter 'pathString' must be a string, not " + typeof pathString
|
||||
);
|
||||
}
|
||||
var allParts = posixSplitPath(pathString);
|
||||
if (!allParts || allParts.length !== 4) {
|
||||
throw new TypeError("Invalid path '" + pathString + "'");
|
||||
}
|
||||
allParts[1] = allParts[1] || '';
|
||||
allParts[2] = allParts[2] || '';
|
||||
allParts[3] = allParts[3] || '';
|
||||
|
||||
return {
|
||||
root: allParts[0],
|
||||
dir: allParts[0] + allParts[1].slice(0, allParts[1].length - 1),
|
||||
base: allParts[2],
|
||||
ext: allParts[3],
|
||||
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
posix.sep = '/';
|
||||
posix.delimiter = ':';
|
||||
|
||||
module.exports = posix;
|
||||
50
build/node_modules/path-posix/package.json
generated
vendored
Normal file
50
build/node_modules/path-posix/package.json
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"_from": "path-posix@^1.0.0",
|
||||
"_id": "path-posix@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-BrJhE/Vr6rBCVFojv6iAA8ysJg8=",
|
||||
"_location": "/path-posix",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "path-posix@^1.0.0",
|
||||
"name": "path-posix",
|
||||
"escapedName": "path-posix",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vulcanize"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/path-posix/-/path-posix-1.0.0.tgz",
|
||||
"_shasum": "06b26113f56beab042545a23bfa88003ccac260f",
|
||||
"_spec": "path-posix@^1.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/vulcanize",
|
||||
"author": {
|
||||
"name": "jden",
|
||||
"email": "jason@denizac.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jden/node-path-posix/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "posix-specific core path module",
|
||||
"homepage": "https://github.com/jden/node-path-posix#readme",
|
||||
"keywords": [
|
||||
"path"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "path-posix",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/jden/node-path-posix.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test-path"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
248
build/node_modules/path-posix/test/test-path.js
generated
vendored
Normal file
248
build/node_modules/path-posix/test/test-path.js
generated
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var path = require('..');
|
||||
|
||||
var f = '/foo/test/simple/test-path.js';
|
||||
|
||||
assert.equal(path.basename(f), 'test-path.js');
|
||||
assert.equal(path.basename(f, '.js'), 'test-path');
|
||||
assert.equal(path.basename(''), '');
|
||||
assert.equal(path.basename('/dir/basename.ext'), 'basename.ext');
|
||||
assert.equal(path.basename('/basename.ext'), 'basename.ext');
|
||||
assert.equal(path.basename('basename.ext'), 'basename.ext');
|
||||
assert.equal(path.basename('basename.ext/'), 'basename.ext');
|
||||
assert.equal(path.basename('basename.ext//'), 'basename.ext');
|
||||
|
||||
// On unix a backslash is just treated as any other character.
|
||||
assert.equal(path.basename('\\dir\\basename.ext'), '\\dir\\basename.ext');
|
||||
assert.equal(path.basename('\\basename.ext'), '\\basename.ext');
|
||||
assert.equal(path.basename('basename.ext'), 'basename.ext');
|
||||
assert.equal(path.basename('basename.ext\\'), 'basename.ext\\');
|
||||
assert.equal(path.basename('basename.ext\\\\'), 'basename.ext\\\\');
|
||||
|
||||
// POSIX filenames may include control characters
|
||||
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
|
||||
var controlCharFilename = 'Icon' + String.fromCharCode(13);
|
||||
assert.equal(path.basename('/a/b/' + controlCharFilename),
|
||||
controlCharFilename);
|
||||
|
||||
assert.equal(path.extname(f), '.js');
|
||||
|
||||
assert.equal(path.dirname(f).substr(-11), 'test/simple');
|
||||
assert.equal(path.dirname('/a/b/'), '/a');
|
||||
assert.equal(path.dirname('/a/b'), '/a');
|
||||
assert.equal(path.dirname('/a'), '/');
|
||||
assert.equal(path.dirname(''), '.');
|
||||
assert.equal(path.dirname('/'), '/');
|
||||
assert.equal(path.dirname('////'), '/');
|
||||
|
||||
|
||||
assert.equal(path.extname(''), '');
|
||||
assert.equal(path.extname('/path/to/file'), '');
|
||||
assert.equal(path.extname('/path/to/file.ext'), '.ext');
|
||||
assert.equal(path.extname('/path.to/file.ext'), '.ext');
|
||||
assert.equal(path.extname('/path.to/file'), '');
|
||||
assert.equal(path.extname('/path.to/.file'), '');
|
||||
assert.equal(path.extname('/path.to/.file.ext'), '.ext');
|
||||
assert.equal(path.extname('/path/to/f.ext'), '.ext');
|
||||
assert.equal(path.extname('/path/to/..ext'), '.ext');
|
||||
assert.equal(path.extname('file'), '');
|
||||
assert.equal(path.extname('file.ext'), '.ext');
|
||||
assert.equal(path.extname('.file'), '');
|
||||
assert.equal(path.extname('.file.ext'), '.ext');
|
||||
assert.equal(path.extname('/file'), '');
|
||||
assert.equal(path.extname('/file.ext'), '.ext');
|
||||
assert.equal(path.extname('/.file'), '');
|
||||
assert.equal(path.extname('/.file.ext'), '.ext');
|
||||
assert.equal(path.extname('.path/file.ext'), '.ext');
|
||||
assert.equal(path.extname('file.ext.ext'), '.ext');
|
||||
assert.equal(path.extname('file.'), '.');
|
||||
assert.equal(path.extname('.'), '');
|
||||
assert.equal(path.extname('./'), '');
|
||||
assert.equal(path.extname('.file.ext'), '.ext');
|
||||
assert.equal(path.extname('.file'), '');
|
||||
assert.equal(path.extname('.file.'), '.');
|
||||
assert.equal(path.extname('.file..'), '.');
|
||||
assert.equal(path.extname('..'), '');
|
||||
assert.equal(path.extname('../'), '');
|
||||
assert.equal(path.extname('..file.ext'), '.ext');
|
||||
assert.equal(path.extname('..file'), '.file');
|
||||
assert.equal(path.extname('..file.'), '.');
|
||||
assert.equal(path.extname('..file..'), '.');
|
||||
assert.equal(path.extname('...'), '.');
|
||||
assert.equal(path.extname('...ext'), '.ext');
|
||||
assert.equal(path.extname('....'), '.');
|
||||
assert.equal(path.extname('file.ext/'), '.ext');
|
||||
assert.equal(path.extname('file.ext//'), '.ext');
|
||||
assert.equal(path.extname('file/'), '');
|
||||
assert.equal(path.extname('file//'), '');
|
||||
assert.equal(path.extname('file./'), '.');
|
||||
assert.equal(path.extname('file.//'), '.');
|
||||
|
||||
// On unix, backspace is a valid name component like any other character.
|
||||
assert.equal(path.extname('.\\'), '');
|
||||
assert.equal(path.extname('..\\'), '.\\');
|
||||
assert.equal(path.extname('file.ext\\'), '.ext\\');
|
||||
assert.equal(path.extname('file.ext\\\\'), '.ext\\\\');
|
||||
assert.equal(path.extname('file\\'), '');
|
||||
assert.equal(path.extname('file\\\\'), '');
|
||||
assert.equal(path.extname('file.\\'), '.\\');
|
||||
assert.equal(path.extname('file.\\\\'), '.\\\\');
|
||||
|
||||
// path.join tests
|
||||
var failures = [];
|
||||
var joinTests =
|
||||
// arguments result
|
||||
[[['.', 'x/b', '..', '/b/c.js'], 'x/b/c.js'],
|
||||
[['/.', 'x/b', '..', '/b/c.js'], '/x/b/c.js'],
|
||||
[['/foo', '../../../bar'], '/bar'],
|
||||
[['foo', '../../../bar'], '../../bar'],
|
||||
[['foo/', '../../../bar'], '../../bar'],
|
||||
[['foo/x', '../../../bar'], '../bar'],
|
||||
[['foo/x', './bar'], 'foo/x/bar'],
|
||||
[['foo/x/', './bar'], 'foo/x/bar'],
|
||||
[['foo/x/', '.', 'bar'], 'foo/x/bar'],
|
||||
[['./'], './'],
|
||||
[['.', './'], './'],
|
||||
[['.', '.', '.'], '.'],
|
||||
[['.', './', '.'], '.'],
|
||||
[['.', '/./', '.'], '.'],
|
||||
[['.', '/////./', '.'], '.'],
|
||||
[['.'], '.'],
|
||||
[['', '.'], '.'],
|
||||
[['', 'foo'], 'foo'],
|
||||
[['foo', '/bar'], 'foo/bar'],
|
||||
[['', '/foo'], '/foo'],
|
||||
[['', '', '/foo'], '/foo'],
|
||||
[['', '', 'foo'], 'foo'],
|
||||
[['foo', ''], 'foo'],
|
||||
[['foo/', ''], 'foo/'],
|
||||
[['foo', '', '/bar'], 'foo/bar'],
|
||||
[['./', '..', '/foo'], '../foo'],
|
||||
[['./', '..', '..', '/foo'], '../../foo'],
|
||||
[['.', '..', '..', '/foo'], '../../foo'],
|
||||
[['', '..', '..', '/foo'], '../../foo'],
|
||||
[['/'], '/'],
|
||||
[['/', '.'], '/'],
|
||||
[['/', '..'], '/'],
|
||||
[['/', '..', '..'], '/'],
|
||||
[[''], '.'],
|
||||
[['', ''], '.'],
|
||||
[[' /foo'], ' /foo'],
|
||||
[[' ', 'foo'], ' /foo'],
|
||||
[[' ', '.'], ' '],
|
||||
[[' ', '/'], ' /'],
|
||||
[[' ', ''], ' '],
|
||||
[['/', 'foo'], '/foo'],
|
||||
[['/', '/foo'], '/foo'],
|
||||
[['/', '//foo'], '/foo'],
|
||||
[['/', '', '/foo'], '/foo'],
|
||||
[['', '/', 'foo'], '/foo'],
|
||||
[['', '/', '/foo'], '/foo']
|
||||
];
|
||||
|
||||
// Run the join tests.
|
||||
joinTests.forEach(function(test) {
|
||||
var actual = path.join.apply(path, test[0]);
|
||||
var expected = test[1];
|
||||
var message = 'path.join(' + test[0].map(JSON.stringify).join(',') + ')' +
|
||||
'\n expect=' + JSON.stringify(expected) +
|
||||
'\n actual=' + JSON.stringify(actual);
|
||||
if (actual !== expected) failures.push('\n' + message);
|
||||
// assert.equal(actual, expected, message);
|
||||
});
|
||||
assert.equal(failures.length, 0, failures.join(''));
|
||||
var joinThrowTests = [true, false, 7, null, {}, undefined, [], NaN];
|
||||
joinThrowTests.forEach(function(test) {
|
||||
assert.throws(function() {
|
||||
path.join(test);
|
||||
}, TypeError);
|
||||
assert.throws(function() {
|
||||
path.resolve(test);
|
||||
}, TypeError);
|
||||
});
|
||||
|
||||
|
||||
// path normalize tests
|
||||
|
||||
assert.equal(path.normalize('./fixtures///b/../b/c.js'),
|
||||
'fixtures/b/c.js');
|
||||
assert.equal(path.normalize('/foo/../../../bar'), '/bar');
|
||||
assert.equal(path.normalize('a//b//../b'), 'a/b');
|
||||
assert.equal(path.normalize('a//b//./c'), 'a/b/c');
|
||||
assert.equal(path.normalize('a//b//.'), 'a/b');
|
||||
|
||||
// path.resolve tests
|
||||
var resolveTests =
|
||||
// arguments result
|
||||
[[['/var/lib', '../', 'file/'], '/var/file'],
|
||||
[['/var/lib', '/../', 'file/'], '/file'],
|
||||
[['a/b/c/', '../../..'], process.cwd()],
|
||||
[['.'], process.cwd()],
|
||||
[['/some/dir', '.', '/absolute/'], '/absolute']];
|
||||
|
||||
var failures = [];
|
||||
resolveTests.forEach(function(test) {
|
||||
var actual = path.resolve.apply(path, test[0]);
|
||||
var expected = test[1];
|
||||
var message = 'path.resolve(' + test[0].map(JSON.stringify).join(',') + ')' +
|
||||
'\n expect=' + JSON.stringify(expected) +
|
||||
'\n actual=' + JSON.stringify(actual);
|
||||
if (actual !== expected) failures.push('\n' + message);
|
||||
// assert.equal(actual, expected, message);
|
||||
});
|
||||
assert.equal(failures.length, 0, failures.join(''));
|
||||
|
||||
// path.isAbsolute tests
|
||||
assert.equal(path.isAbsolute('/home/foo'), true);
|
||||
assert.equal(path.isAbsolute('/home/foo/..'), true);
|
||||
assert.equal(path.isAbsolute('bar/'), false);
|
||||
assert.equal(path.isAbsolute('./baz'), false);
|
||||
|
||||
// path.relative tests
|
||||
var relativeTests =
|
||||
// arguments result
|
||||
[['/var/lib', '/var', '..'],
|
||||
['/var/lib', '/bin', '../../bin'],
|
||||
['/var/lib', '/var/lib', ''],
|
||||
['/var/lib', '/var/apache', '../apache'],
|
||||
['/var/', '/var/lib', 'lib'],
|
||||
['/', '/var/lib', 'var/lib']];
|
||||
var failures = [];
|
||||
relativeTests.forEach(function(test) {
|
||||
var actual = path.relative(test[0], test[1]);
|
||||
var expected = test[2];
|
||||
var message = 'path.relative(' +
|
||||
test.slice(0, 2).map(JSON.stringify).join(',') +
|
||||
')' +
|
||||
'\n expect=' + JSON.stringify(expected) +
|
||||
'\n actual=' + JSON.stringify(actual);
|
||||
if (actual !== expected) failures.push('\n' + message);
|
||||
});
|
||||
assert.equal(failures.length, 0, failures.join(''));
|
||||
|
||||
assert.equal(path.sep, '/');
|
||||
|
||||
// path.delimiter tests
|
||||
assert.equal(path.delimiter, ':');
|
||||
Reference in New Issue
Block a user