init
This commit is contained in:
4
node_modules/string-argv/.npmignore
generated
vendored
Normal file
4
node_modules/string-argv/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
test/
|
||||
.eslintrc.json
|
||||
.gitignore
|
50
node_modules/string-argv/README.md
generated
vendored
Normal file
50
node_modules/string-argv/README.md
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
#What is it?
|
||||
string-argv parses a string into an argument array to mimic process.argv.
|
||||
This is useful when testing Command Line Utilities that you want to pass arguments to and is the opposite of what the other argv utilities do.
|
||||
|
||||
#Installation
|
||||
|
||||
```
|
||||
npm install string-argv --save
|
||||
```
|
||||
|
||||
#Usage
|
||||
|
||||
```js
|
||||
var stringArgv = require('string-argv');
|
||||
var args = stringArgv(
|
||||
'-testing test -valid=true --quotes "test quotes" "nested \'quotes\'" --key="some value" --title="Peter\'s Friends"',
|
||||
'node',
|
||||
'testing.js'
|
||||
);
|
||||
|
||||
//legacy
|
||||
var args2 = stringArgv.parseArgsStringToArgv(
|
||||
'-testing test -valid=true --quotes "test quotes" "nested \'quotes\'" --key="some value" --title="Peter\'s Friends"',
|
||||
'node',
|
||||
'testing.js'
|
||||
);
|
||||
|
||||
console.log(args);
|
||||
/** output
|
||||
[ 'node',
|
||||
'testing.js',
|
||||
'-testing',
|
||||
'test',
|
||||
'-valid=true',
|
||||
'--quotes',
|
||||
'test quotes',
|
||||
'nested \'quotes\'',
|
||||
'--key="some value"',
|
||||
'--title="Peter\'s Friends"' ]
|
||||
**/
|
||||
```
|
||||
|
||||
##params
|
||||
|
||||
__required__: __arguments__ String: arguments that you would normally pass to the command line.
|
||||
|
||||
__optional__: __environment__ String: Adds to the environment position in the argv array. If ommitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.
|
||||
|
||||
__optional__: __file__ String: file that called the arguments. If omitted then there is no need to call argv.split(2) to remove the environment/file values. However if your cli.parse method expects a valid argv value then you should include this value.
|
35
node_modules/string-argv/index.js
generated
vendored
Normal file
35
node_modules/string-argv/index.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = parseArgsStringToArgv;
|
||||
module.exports.parseArgsStringToArgv = parseArgsStringToArgv;
|
||||
|
||||
function parseArgsStringToArgv(value, env, file) {
|
||||
// ([^\s'"]+(['"])([^\2]*?)\2) Match `text"quotes text"`
|
||||
|
||||
// [^\s'"] or Match if not a space ' or "
|
||||
|
||||
// (['"])([^\4]*?)\4 or Match "quoted text" without quotes
|
||||
// `\2` and `\4` are a backreference to the quote style (' or ") captured
|
||||
var myRegexp = /([^\s'"]+(['"])([^\2]*?)\2)|[^\s'"]+|(['"])([^\4]*?)\4/gi;
|
||||
var myString = value;
|
||||
var myArray = [
|
||||
];
|
||||
if (env) {
|
||||
myArray.push(env);
|
||||
}
|
||||
if (file) {
|
||||
myArray.push(file);
|
||||
}
|
||||
var match;
|
||||
do {
|
||||
// Each call to exec returns the next regex match as an array
|
||||
match = myRegexp.exec(myString);
|
||||
if (match !== null) {
|
||||
// Index 1 in the array is the captured group if it exists
|
||||
// Index 0 is the matched text, which we use if no captured group exists
|
||||
myArray.push(match[1] || match[5] || match[0]);
|
||||
}
|
||||
} while (match !== null);
|
||||
|
||||
return myArray;
|
||||
}
|
36
node_modules/string-argv/package.json
generated
vendored
Normal file
36
node_modules/string-argv/package.json
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "string-argv",
|
||||
"description": "string-argv parses a string into an argument array to mimic process.argv. This is useful when testing Command Line Utilities that you want to pass arguments to.",
|
||||
"version": "0.0.2",
|
||||
"author": {
|
||||
"name": "Anthony McCormick",
|
||||
"email": "anthony.mccormick AT gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"logger"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "jasmine JASMINE_CONFIG_PATH=test/config.json --verbose --color --captureExceptions && npm run lint"
|
||||
},
|
||||
"main": "index",
|
||||
"engines": {
|
||||
"node": ">=0.6.19"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mccormicka/string-argv/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mccormicka/string-argv"
|
||||
},
|
||||
"homepage": "https://github.com/mccormicka/string-argv",
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"eslint": "^2.0.0",
|
||||
"eslint-config-cellule": "^3.0.0",
|
||||
"jasmine": "^2.4.1"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user