From 7fff4499fd915bcea3fa93b1aa8b35f4fe7a6027 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 28 May 2017 00:38:50 +0200 Subject: add linting (and some initial fixes) --- node_modules/path-parse/.travis.yml | 9 ++++ node_modules/path-parse/README.md | 44 +++++++++++++++++ node_modules/path-parse/index.js | 93 ++++++++++++++++++++++++++++++++++++ node_modules/path-parse/index.min.js | 1 + node_modules/path-parse/package.json | 33 +++++++++++++ node_modules/path-parse/test.js | 77 +++++++++++++++++++++++++++++ node_modules/path-parse/test.min.js | 1 + 7 files changed, 258 insertions(+) create mode 100644 node_modules/path-parse/.travis.yml create mode 100644 node_modules/path-parse/README.md create mode 100644 node_modules/path-parse/index.js create mode 100644 node_modules/path-parse/index.min.js create mode 100644 node_modules/path-parse/package.json create mode 100644 node_modules/path-parse/test.js create mode 100644 node_modules/path-parse/test.min.js (limited to 'node_modules/path-parse') diff --git a/node_modules/path-parse/.travis.yml b/node_modules/path-parse/.travis.yml new file mode 100644 index 000000000..dae31da96 --- /dev/null +++ b/node_modules/path-parse/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "0.12" + - "0.11" + - "0.10" + - "0.10.12" + - "0.8" + - "0.6" + - "iojs" diff --git a/node_modules/path-parse/README.md b/node_modules/path-parse/README.md new file mode 100644 index 000000000..c6af02c6c --- /dev/null +++ b/node_modules/path-parse/README.md @@ -0,0 +1,44 @@ +# path-parse [![Build Status](https://travis-ci.org/jbgutierrez/path-parse.svg?branch=master)](https://travis-ci.org/jbgutierrez/path-parse) + +> Node.js [`path.parse(pathString)`](https://nodejs.org/api/path.html#path_path_parse_pathstring) ponyfill. + +> Ponyfill: A polyfill that doesn't overwrite the native method + +## 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) diff --git a/node_modules/path-parse/index.js b/node_modules/path-parse/index.js new file mode 100644 index 000000000..3b7601fe4 --- /dev/null +++ b/node_modules/path-parse/index.js @@ -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; diff --git a/node_modules/path-parse/index.min.js b/node_modules/path-parse/index.min.js new file mode 100644 index 000000000..027da511d --- /dev/null +++ b/node_modules/path-parse/index.min.js @@ -0,0 +1 @@ +"use strict";var isWindows=process.platform==="win32";var splitDeviceRe=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;var splitTailRe=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;var win32={};function win32SplitPath(b){var a=splitDeviceRe.exec(b),g=(a[1]||"")+(a[2]||""),e=a[3]||"";var d=splitTailRe.exec(e),c=d[1],h=d[2],f=d[3];return[g,c,h,f]}win32.parse=function(b){if(typeof b!=="string"){throw new TypeError("Parameter 'pathString' must be a string, not "+typeof b)}var a=win32SplitPath(b);if(!a||a.length!==4){throw new TypeError("Invalid path '"+b+"'")}return{root:a[0],dir:a[0]+a[1].slice(0,-1),base:a[2],ext:a[3],name:a[2].slice(0,a[2].length-a[3].length)}};var splitPathRe=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var posix={};function posixSplitPath(a){return splitPathRe.exec(a).slice(1)}posix.parse=function(b){if(typeof b!=="string"){throw new TypeError("Parameter 'pathString' must be a string, not "+typeof b)}var a=posixSplitPath(b);if(!a||a.length!==4){throw new TypeError("Invalid path '"+b+"'")}a[1]=a[1]||"";a[2]=a[2]||"";a[3]=a[3]||"";return{root:a[0],dir:a[0]+a[1].slice(0,-1),base:a[2],ext:a[3],name:a[2].slice(0,a[2].length-a[3].length)}};if(isWindows){module.exports=win32.parse}else{module.exports=posix.parse}module.exports.posix=posix.parse;module.exports.win32=win32.parse; \ No newline at end of file diff --git a/node_modules/path-parse/package.json b/node_modules/path-parse/package.json new file mode 100644 index 000000000..28dc7a5e5 --- /dev/null +++ b/node_modules/path-parse/package.json @@ -0,0 +1,33 @@ +{ + "name": "path-parse", + "version": "1.0.5", + "description": "Node.js path.parse() ponyfill", + "main": "index.js", + "scripts": { + "test": "node test.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/jbgutierrez/path-parse.git" + }, + "keywords": [ + "path", + "paths", + "file", + "dir", + "parse", + "built-in", + "util", + "utils", + "core", + "ponyfill", + "polyfill", + "shim" + ], + "author": "Javier Blanco ", + "license": "MIT", + "bugs": { + "url": "https://github.com/jbgutierrez/path-parse/issues" + }, + "homepage": "https://github.com/jbgutierrez/path-parse#readme" +} diff --git a/node_modules/path-parse/test.js b/node_modules/path-parse/test.js new file mode 100644 index 000000000..0b30c1239 --- /dev/null +++ b/node_modules/path-parse/test.js @@ -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]); + }); +} diff --git a/node_modules/path-parse/test.min.js b/node_modules/path-parse/test.min.js new file mode 100644 index 000000000..90cc2b85a --- /dev/null +++ b/node_modules/path-parse/test.min.js @@ -0,0 +1 @@ +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"],[{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(a){errors.forEach(function(c){try{a(c.input)}catch(b){assert.ok(b instanceof TypeError);assert.ok(c.message.test(b.message),"expected "+c.message+" to match "+b.message);return}assert.fail("should have thrown")})}function checkParseFormat(b,a){a.forEach(function(c){assert.deepEqual(b(c[1]),c[0])})}; \ No newline at end of file -- cgit v1.2.3