Project rename
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.12"
|
||||
- "0.11"
|
||||
- "0.10"
|
||||
- "0.10.12"
|
||||
- "0.8"
|
||||
- "0.6"
|
||||
- "iojs"
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Javier Blanco
|
||||
|
||||
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.
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
# path-parse [](https://travis-ci.org/jbgutierrez/path-parse)
|
||||
|
||||
> Node.js [`path.parse(pathString)`](https://nodejs.org/api/path.html#path_path_parse_pathstring) [ponyfill](https://ponyfill.com).
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save path-parse
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var pathParse = require('path-parse');
|
||||
|
||||
pathParse('/home/user/dir/file.txt');
|
||||
//=> {
|
||||
// root : "/",
|
||||
// dir : "/home/user/dir",
|
||||
// base : "file.txt",
|
||||
// ext : ".txt",
|
||||
// name : "file"
|
||||
// }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
See [`path.parse(pathString)`](https://nodejs.org/api/path.html#path_path_parse_pathstring) docs.
|
||||
|
||||
### pathParse(path)
|
||||
|
||||
### pathParse.posix(path)
|
||||
|
||||
The Posix specific version.
|
||||
|
||||
### pathParse.win32(path)
|
||||
|
||||
The Windows specific version.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Javier Blanco](http://jbgutierrez.info)
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
'use strict';
|
||||
|
||||
var isWindows = process.platform === 'win32';
|
||||
|
||||
// Regex to split a windows path into three parts: [*, device, slash,
|
||||
// tail] windows-only
|
||||
var splitDeviceRe =
|
||||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
||||
|
||||
// Regex to split the tail part of the above into [*, dir, basename, ext]
|
||||
var splitTailRe =
|
||||
/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
|
||||
|
||||
var win32 = {};
|
||||
|
||||
// Function to split a filename into [root, dir, basename, ext]
|
||||
function win32SplitPath(filename) {
|
||||
// Separate device+slash from tail
|
||||
var result = splitDeviceRe.exec(filename),
|
||||
device = (result[1] || '') + (result[2] || ''),
|
||||
tail = result[3] || '';
|
||||
// Split the tail into dir, basename and extension
|
||||
var result2 = splitTailRe.exec(tail),
|
||||
dir = result2[1],
|
||||
basename = result2[2],
|
||||
ext = result2[3];
|
||||
return [device, dir, basename, ext];
|
||||
}
|
||||
|
||||
win32.parse = function(pathString) {
|
||||
if (typeof pathString !== 'string') {
|
||||
throw new TypeError(
|
||||
"Parameter 'pathString' must be a string, not " + typeof pathString
|
||||
);
|
||||
}
|
||||
var allParts = win32SplitPath(pathString);
|
||||
if (!allParts || allParts.length !== 4) {
|
||||
throw new TypeError("Invalid path '" + pathString + "'");
|
||||
}
|
||||
return {
|
||||
root: allParts[0],
|
||||
dir: allParts[0] + allParts[1].slice(0, -1),
|
||||
base: allParts[2],
|
||||
ext: allParts[3],
|
||||
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
posix.parse = function(pathString) {
|
||||
if (typeof pathString !== 'string') {
|
||||
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, -1),
|
||||
base: allParts[2],
|
||||
ext: allParts[3],
|
||||
name: allParts[2].slice(0, allParts[2].length - allParts[3].length)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
if (isWindows)
|
||||
module.exports = win32.parse;
|
||||
else /* posix */
|
||||
module.exports = posix.parse;
|
||||
|
||||
module.exports.posix = posix.parse;
|
||||
module.exports.win32 = win32.parse;
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "path-parse@^1.0.6",
|
||||
"scope": null,
|
||||
"escapedName": "path-parse",
|
||||
"name": "path-parse",
|
||||
"rawSpec": "^1.0.6",
|
||||
"spec": ">=1.0.6 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/resolve"
|
||||
]
|
||||
],
|
||||
"_from": "path-parse@>=1.0.6 <2.0.0",
|
||||
"_id": "path-parse@1.0.6",
|
||||
"_inCache": true,
|
||||
"_location": "/path-parse",
|
||||
"_nodeVersion": "10.1.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/path-parse_1.0.6_1533537156798_0.8841048033486669"
|
||||
},
|
||||
"_npmUser": {
|
||||
"name": "jbgutierrez",
|
||||
"email": "jbgutierrez@gmail.com"
|
||||
},
|
||||
"_npmVersion": "5.6.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "path-parse@^1.0.6",
|
||||
"scope": null,
|
||||
"escapedName": "path-parse",
|
||||
"name": "path-parse",
|
||||
"rawSpec": "^1.0.6",
|
||||
"spec": ">=1.0.6 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/resolve"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"_shasum": "d62dbb5679405d72c4737ec58600e9ddcf06d24c",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "path-parse@^1.0.6",
|
||||
"_where": "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/resolve",
|
||||
"author": {
|
||||
"name": "Javier Blanco",
|
||||
"email": "http://jbgutierrez.info"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jbgutierrez/path-parse/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Node.js path.parse() ponyfill",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
|
||||
"shasum": "d62dbb5679405d72c4737ec58600e9ddcf06d24c",
|
||||
"tarball": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"fileCount": 6,
|
||||
"unpackedSize": 9029,
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbZ+uFCRA9TVsSAnZWagAA5GwQAI25pLPhwQijTCAsGUSO\nMWrhq2ReoJWhubV2hGPMRIhX7A1v1ov9AmZYutpxnRggBx472fzbMJ5aiQg1\naL1fONHaK9MDDY87zSWRKOAJgvawncbiY2apXJUnBwVNaUeBPTm42RA9bOyO\nkLTbPbQBNTXm7js1U1a47+rOLlvHWusPP1A1+5gPbqr56XqIw/Yh7fz5zH1M\nzNKX9yOlWp1hTXosNQ3TQqRWGp69OqUw/a2B2ddvGre/bv+oDmyiDCFBNPj6\nyVXRkvzThxoVSjkcjspz/UEFZMaFonc9I71q04hK9Aq53USD+ZK+dsLFMaLL\nzgZeiNfMJur2fyXSEZwSccHqCbZ/5uf92egs9zbquf+ULyn2bzk7tZb1QGQp\nur0sH7fFQVoLgSLlmnXXv+uawNY3f51oL4snI56Ik5Zj70u6nKJYIGgIpBj6\nlK1FujTUFojzic9hRd3uc30LLoNbdJHF7dL7FqVrM4bW9/NKmuPsLl8Aiu9M\npH66W3tXW2WrzZuR7wAD12Rt/6n5XIrNJeEjP9l6bEx2tsTka2Z7TgaVXWCD\n2dVCyzk+Tp9OvqXOi+7IAMis+NlmZjtdVJ7js5at12DH7iJY1gaYvCH6b1+C\nAA1T9+EFrMd8di48t20EZEppXWm4nAvRa/6lHEG9VYuK4reR39V/Gn95xksb\n1Md/\r\n=QlIN\r\n-----END PGP SIGNATURE-----\r\n"
|
||||
},
|
||||
"gitHead": "97efc90ce24455d23ec6acedf47589df46e48ea0",
|
||||
"homepage": "https://github.com/jbgutierrez/path-parse#readme",
|
||||
"keywords": [
|
||||
"path",
|
||||
"paths",
|
||||
"file",
|
||||
"dir",
|
||||
"parse",
|
||||
"built-in",
|
||||
"util",
|
||||
"utils",
|
||||
"core",
|
||||
"ponyfill",
|
||||
"polyfill",
|
||||
"shim"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jbgutierrez",
|
||||
"email": "jbgutierrez@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "path-parse",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jbgutierrez/path-parse.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"version": "1.0.6"
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
var assert = require('assert');
|
||||
var pathParse = require('./index');
|
||||
|
||||
var winParseTests = [
|
||||
[{ root: 'C:\\', dir: 'C:\\path\\dir', base: 'index.html', ext: '.html', name: 'index' }, 'C:\\path\\dir\\index.html'],
|
||||
[{ root: 'C:\\', dir: 'C:\\another_path\\DIR\\1\\2\\33', base: 'index', ext: '', name: 'index' }, 'C:\\another_path\\DIR\\1\\2\\33\\index'],
|
||||
[{ root: '', dir: 'another_path\\DIR with spaces\\1\\2\\33', base: 'index', ext: '', name: 'index' }, 'another_path\\DIR with spaces\\1\\2\\33\\index'],
|
||||
[{ root: '\\', dir: '\\foo', base: 'C:', ext: '', name: 'C:' }, '\\foo\\C:'],
|
||||
[{ root: '', dir: '', base: 'file', ext: '', name: 'file' }, 'file'],
|
||||
[{ root: '', dir: '.', base: 'file', ext: '', name: 'file' }, '.\\file'],
|
||||
|
||||
// unc
|
||||
[{ root: '\\\\server\\share\\', dir: '\\\\server\\share\\', base: 'file_path', ext: '', name: 'file_path' }, '\\\\server\\share\\file_path'],
|
||||
[{ root: '\\\\server two\\shared folder\\', dir: '\\\\server two\\shared folder\\', base: 'file path.zip', ext: '.zip', name: 'file path' }, '\\\\server two\\shared folder\\file path.zip'],
|
||||
[{ root: '\\\\teela\\admin$\\', dir: '\\\\teela\\admin$\\', base: 'system32', ext: '', name: 'system32' }, '\\\\teela\\admin$\\system32'],
|
||||
[{ root: '\\\\?\\UNC\\', dir: '\\\\?\\UNC\\server', base: 'share', ext: '', name: 'share' }, '\\\\?\\UNC\\server\\share']
|
||||
];
|
||||
|
||||
var winSpecialCaseFormatTests = [
|
||||
[{dir: 'some\\dir'}, 'some\\dir\\'],
|
||||
[{base: 'index.html'}, 'index.html'],
|
||||
[{}, '']
|
||||
];
|
||||
|
||||
var unixParseTests = [
|
||||
[{ root: '/', dir: '/home/user/dir', base: 'file.txt', ext: '.txt', name: 'file' }, '/home/user/dir/file.txt'],
|
||||
[{ root: '/', dir: '/home/user/a dir', base: 'another File.zip', ext: '.zip', name: 'another File' }, '/home/user/a dir/another File.zip'],
|
||||
[{ root: '/', dir: '/home/user/a dir/', base: 'another&File.', ext: '.', name: 'another&File' }, '/home/user/a dir//another&File.'],
|
||||
[{ root: '/', dir: '/home/user/a$$$dir/', base: 'another File.zip', ext: '.zip', name: 'another File' }, '/home/user/a$$$dir//another File.zip'],
|
||||
[{ root: '', dir: 'user/dir', base: 'another File.zip', ext: '.zip', name: 'another File' }, 'user/dir/another File.zip'],
|
||||
[{ root: '', dir: '', base: 'file', ext: '', name: 'file' }, 'file'],
|
||||
[{ root: '', dir: '', base: '.\\file', ext: '', name: '.\\file' }, '.\\file'],
|
||||
[{ root: '', dir: '.', base: 'file', ext: '', name: 'file' }, './file'],
|
||||
[{ root: '', dir: '', base: 'C:\\foo', ext: '', name: 'C:\\foo' }, 'C:\\foo']
|
||||
];
|
||||
|
||||
var unixSpecialCaseFormatTests = [
|
||||
[{dir: 'some/dir'}, 'some/dir/'],
|
||||
[{base: 'index.html'}, 'index.html'],
|
||||
[{}, '']
|
||||
];
|
||||
|
||||
var errors = [
|
||||
{input: null, message: /Parameter 'pathString' must be a string, not/},
|
||||
{input: {}, message: /Parameter 'pathString' must be a string, not object/},
|
||||
{input: true, message: /Parameter 'pathString' must be a string, not boolean/},
|
||||
{input: 1, message: /Parameter 'pathString' must be a string, not number/},
|
||||
{input: undefined, message: /Parameter 'pathString' must be a string, not undefined/},
|
||||
];
|
||||
|
||||
checkParseFormat(pathParse.win32, winParseTests);
|
||||
checkParseFormat(pathParse.posix, unixParseTests);
|
||||
checkErrors(pathParse.win32);
|
||||
checkErrors(pathParse.posix);
|
||||
|
||||
function checkErrors(parse) {
|
||||
errors.forEach(function(errorCase) {
|
||||
try {
|
||||
parse(errorCase.input);
|
||||
} catch(err) {
|
||||
assert.ok(err instanceof TypeError);
|
||||
assert.ok(
|
||||
errorCase.message.test(err.message),
|
||||
'expected ' + errorCase.message + ' to match ' + err.message
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
assert.fail('should have thrown');
|
||||
});
|
||||
}
|
||||
|
||||
function checkParseFormat(parse, testCases) {
|
||||
testCases.forEach(function(testCase) {
|
||||
assert.deepEqual(parse(testCase[1]), testCase[0]);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user