diff options
Diffstat (limited to 'node_modules/yargs-parser')
-rw-r--r-- | node_modules/yargs-parser/CHANGELOG.md | 75 | ||||
-rw-r--r-- | node_modules/yargs-parser/README.md | 45 | ||||
-rw-r--r-- | node_modules/yargs-parser/index.js | 56 | ||||
-rw-r--r-- | node_modules/yargs-parser/lib/tokenize-arg-string.js | 6 | ||||
-rw-r--r-- | node_modules/yargs-parser/node_modules/camelcase/index.js | 56 | ||||
-rw-r--r-- | node_modules/yargs-parser/node_modules/camelcase/license | 21 | ||||
-rw-r--r-- | node_modules/yargs-parser/node_modules/camelcase/package.json | 39 | ||||
-rw-r--r-- | node_modules/yargs-parser/node_modules/camelcase/readme.md | 57 | ||||
-rw-r--r-- | node_modules/yargs-parser/package.json | 8 |
9 files changed, 165 insertions, 198 deletions
diff --git a/node_modules/yargs-parser/CHANGELOG.md b/node_modules/yargs-parser/CHANGELOG.md index cd060f3c6..f9e7c6237 100644 --- a/node_modules/yargs-parser/CHANGELOG.md +++ b/node_modules/yargs-parser/CHANGELOG.md @@ -2,6 +2,81 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +<a name="8.0.0"></a> +# [8.0.0](https://github.com/yargs/yargs-parser/compare/v7.0.0...v8.0.0) (2017-10-05) + + +### Bug Fixes + +* Ignore multiple spaces between arguments. ([#100](https://github.com/yargs/yargs-parser/issues/100)) ([d137227](https://github.com/yargs/yargs-parser/commit/d137227)) + + +### Features + +* allow configuration of prefix for boolean negation ([#94](https://github.com/yargs/yargs-parser/issues/94)) ([00bde7d](https://github.com/yargs/yargs-parser/commit/00bde7d)) +* reworking how numbers are parsed ([#104](https://github.com/yargs/yargs-parser/issues/104)) ([fba00eb](https://github.com/yargs/yargs-parser/commit/fba00eb)) + + +### BREAKING CHANGES + +* strings that fail `Number.isSafeInteger()` are no longer coerced into numbers. + + + +<a name="7.0.0"></a> +# [7.0.0](https://github.com/yargs/yargs-parser/compare/v6.0.1...v7.0.0) (2017-05-02) + + +### Chores + +* revert populate-- logic ([#91](https://github.com/yargs/yargs-parser/issues/91)) ([6003e6d](https://github.com/yargs/yargs-parser/commit/6003e6d)) + + +### BREAKING CHANGES + +* populate-- now defaults to false. + + + +<a name="6.0.1"></a> +## [6.0.1](https://github.com/yargs/yargs-parser/compare/v6.0.0...v6.0.1) (2017-05-01) + + +### Bug Fixes + +* default '--' to undefined when not provided; this is closer to the array API ([#90](https://github.com/yargs/yargs-parser/issues/90)) ([4e739cc](https://github.com/yargs/yargs-parser/commit/4e739cc)) + + + +<a name="6.0.0"></a> +# [6.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v6.0.0) (2017-05-01) + + +### Bug Fixes + +* environment variables should take precedence over config file ([#81](https://github.com/yargs/yargs-parser/issues/81)) ([76cee1f](https://github.com/yargs/yargs-parser/commit/76cee1f)) +* parsing hints should apply for dot notation keys ([#86](https://github.com/yargs/yargs-parser/issues/86)) ([3e47d62](https://github.com/yargs/yargs-parser/commit/3e47d62)) + + +### Chores + +* upgrade to newest version of camelcase ([#87](https://github.com/yargs/yargs-parser/issues/87)) ([f1903aa](https://github.com/yargs/yargs-parser/commit/f1903aa)) + + +### Features + +* add -- option which allows arguments after the -- flag to be returned separated from positional arguments ([#84](https://github.com/yargs/yargs-parser/issues/84)) ([2572ca8](https://github.com/yargs/yargs-parser/commit/2572ca8)) +* when parsing stops, we now populate "--" by default ([#88](https://github.com/yargs/yargs-parser/issues/88)) ([cd666db](https://github.com/yargs/yargs-parser/commit/cd666db)) + + +### BREAKING CHANGES + +* rather than placing arguments in "_", when parsing is stopped via "--"; we now populate an array called "--" by default. +* camelcase now requires Node 4+. +* environment variables will now override config files (args, env, config-file, config-object) + + + <a name="5.0.0"></a> # [5.0.0](https://github.com/yargs/yargs-parser/compare/v4.2.1...v5.0.0) (2017-02-18) diff --git a/node_modules/yargs-parser/README.md b/node_modules/yargs-parser/README.md index 6d5916c33..a368e632b 100644 --- a/node_modules/yargs-parser/README.md +++ b/node_modules/yargs-parser/README.md @@ -11,7 +11,7 @@ The mighty option parser used by [yargs](https://github.com/yargs/yargs). visit the [yargs website](http://yargs.js.org/) for more examples, and thorough usage instructions. -<img width="250" src="https://github.com/yargs/yargs-parser/blob/master/yargs-logo.png"> +<img width="250" src="https://raw.githubusercontent.com/yargs/yargs-parser/master/yargs-logo.png"> ## Example @@ -72,12 +72,14 @@ Parses command line arguments returning a simple mapping of keys and values. * `opts.string`: keys should be treated as strings (even if they resemble a number `-x 33`). * `opts.configuration`: provide configuration options to the yargs-parser (see: [configuration](#configuration)). * `opts.number`: keys should be treated as numbers. + * `opts['--']`: arguments after the end-of-options flag `--` will be set to the `argv.['--']` array instead of being set to the `argv._` array. **returns:** * `obj`: an object representing the parsed value of `args` * `key/value`: key value pairs for each argument and their aliases. * `_`: an array representing the positional arguments. + * [optional] `--`: an array with arguments after the end-of-options flag `--`. ### require('yargs-parser').detailed(args, opts={}) @@ -100,6 +102,7 @@ yargs engine. * `configuration`: the configuration loaded from the `yargs` stanza in package.json. <a name="configuration"></a> + ### Configuration The yargs-parser applies several automated transformations on the keys provided @@ -247,6 +250,46 @@ node example.js -x 1 2 -x 3 4 { _: [], x: [[1, 2], [3, 4]] } ``` +### negation prefix + +* default: `no-` +* key: `negation-prefix` + +The prefix to use for negated boolean variables. + +```sh +node example.js --no-foo +{ _: [], foo: false } +``` + +_if set to `quux`:_ + +```sh +node example.js --quuxfoo +{ _: [], foo: false } +``` + +### populate -- + +* default: `false`. +* key: `populate--` + +Should unparsed flags be stored in `--` or `_`. + +_If disabled:_ + +```sh +node example.js a -b -- x y +{ _: [ 'a', 'x', 'y' ], b: true } +``` + +_If enabled:_ + +```sh +node example.js a -b -- x y +{ _: [ 'a' ], '--': [ 'x', 'y' ], b: true } +``` + ## Special Thanks The yargs project evolves from optimist and minimist. It owes its diff --git a/node_modules/yargs-parser/index.js b/node_modules/yargs-parser/index.js index b71faf584..c06d93707 100644 --- a/node_modules/yargs-parser/index.js +++ b/node_modules/yargs-parser/index.js @@ -16,12 +16,16 @@ function parse (args, opts) { 'dot-notation': true, 'parse-numbers': true, 'boolean-negation': true, + 'negation-prefix': 'no-', 'duplicate-arguments-array': true, - 'flatten-duplicate-arrays': true + 'flatten-duplicate-arrays': true, + 'populate--': false }, opts.configuration) var defaults = opts.default || {} var configObjects = opts.configObjects || [] var envPrefix = opts.envPrefix + var notFlagsOption = configuration['populate--'] + var notFlagsArgv = notFlagsOption ? '--' : '_' var newAliases = {} // allow a i18n handler to be passed in, default to a fake one (util.format). var __ = opts.__ || function (str) { @@ -42,6 +46,7 @@ function parse (args, opts) { coercions: {} } var negative = /^-[0-9]+(\.[0-9]+)?/ + var negatedBoolean = new RegExp('^--' + configuration['negation-prefix'] + '(.+)') ;[].concat(opts.array).filter(Boolean).forEach(function (key) { flags.arrays[key] = true @@ -138,8 +143,8 @@ function parse (args, opts) { } else { setArg(m[1], m[2]) } - } else if (arg.match(/^--no-.+/) && configuration['boolean-negation']) { - key = arg.match(/^--no-(.+)/)[1] + } else if (arg.match(negatedBoolean) && configuration['boolean-negation']) { + key = arg.match(negatedBoolean)[1] setArg(key, false) // -- seperated by space. @@ -265,9 +270,7 @@ function parse (args, opts) { } } } else { - argv._.push( - flags.strings['_'] || !isNumber(arg) ? arg : Number(arg) - ) + argv._.push(maybeCoerceNumber('_', arg)) } } @@ -289,8 +292,10 @@ function parse (args, opts) { if (!hasKey(argv, key.split('.'))) setArg(key, 0) }) + // '--' defaults to undefined. + if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [] notFlags.forEach(function (key) { - argv._.push(key) + argv[notFlagsArgv].push(key) }) // how many arguments should we consume, based @@ -341,10 +346,8 @@ function parse (args, opts) { function setArg (key, val) { unsetDefaulted(key) - if (/-/.test(key) && !(flags.aliases[key] && flags.aliases[key].length) && configuration['camel-case-expansion']) { - var c = camelCase(key) - flags.aliases[key] = [c] - newAliases[c] = true + if (/-/.test(key) && configuration['camel-case-expansion']) { + addNewAlias(key, camelCase(key)) } var value = processValue(key, val) @@ -389,17 +392,23 @@ function parse (args, opts) { } } + function addNewAlias (key, alias) { + if (!(flags.aliases[key] && flags.aliases[key].length)) { + flags.aliases[key] = [alias] + newAliases[alias] = true + } + if (!(flags.aliases[alias] && flags.aliases[alias].length)) { + addNewAlias(alias, key) + } + } + function processValue (key, val) { // handle parsing boolean arguments --foo=true --bar false. if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) { if (typeof val === 'string') val = val === 'true' } - var value = val - if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.coercions)) { - if (isNumber(val)) value = Number(val) - if (!isUndefined(val) && !isNumber(val) && checkAllAliases(key, flags.numbers)) value = NaN - } + var value = maybeCoerceNumber(key, val) // increment a count given as arg (either no value or value parsed as boolean) if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) { @@ -414,6 +423,14 @@ function parse (args, opts) { return value } + function maybeCoerceNumber (key, value) { + if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.coercions)) { + const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(parseInt(value))) + if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) value = Number(value) + } + return value + } + // set args from config.json file, this should be // applied last so that defaults can be applied. function setConfig (argv) { @@ -558,7 +575,7 @@ function parse (args, opts) { var key = keys[keys.length - 1] - var isTypeArray = checkAllAliases(key, flags.arrays) + var isTypeArray = checkAllAliases(keys.join('.'), flags.arrays) var isValueArray = Array.isArray(value) var duplicate = configuration['duplicate-arguments-array'] @@ -595,7 +612,9 @@ function parse (args, opts) { flags.aliases[key].concat(key).forEach(function (x) { if (/-/.test(x) && configuration['camel-case-expansion']) { var c = camelCase(x) - flags.aliases[key].push(c) + if (flags.aliases[key].indexOf(c) === -1) { + flags.aliases[key].push(c) + } newAliases[c] = true } }) @@ -657,7 +676,6 @@ function parse (args, opts) { } function isNumber (x) { - if (!configuration['parse-numbers']) return false if (typeof x === 'number') return true if (/^0x[0-9a-f]+$/i.test(x)) return true return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x) diff --git a/node_modules/yargs-parser/lib/tokenize-arg-string.js b/node_modules/yargs-parser/lib/tokenize-arg-string.js index 23d39e1fe..70154425c 100644 --- a/node_modules/yargs-parser/lib/tokenize-arg-string.js +++ b/node_modules/yargs-parser/lib/tokenize-arg-string.js @@ -3,16 +3,20 @@ module.exports = function (argString) { if (Array.isArray(argString)) return argString var i = 0 + var prevC = null var c = null var opening = null var args = [] for (var ii = 0; ii < argString.length; ii++) { + prevC = c c = argString.charAt(ii) // split on spaces unless we're in quotes. if (c === ' ' && !opening) { - i++ + if (!(prevC === ' ')) { + i++ + } continue } diff --git a/node_modules/yargs-parser/node_modules/camelcase/index.js b/node_modules/yargs-parser/node_modules/camelcase/index.js deleted file mode 100644 index 5670f73f2..000000000 --- a/node_modules/yargs-parser/node_modules/camelcase/index.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -function preserveCamelCase(str) { - var isLastCharLower = false; - - for (var i = 0; i < str.length; i++) { - var c = str.charAt(i); - - if (isLastCharLower && (/[a-zA-Z]/).test(c) && c.toUpperCase() === c) { - str = str.substr(0, i) + '-' + str.substr(i); - isLastCharLower = false; - i++; - } else { - isLastCharLower = (c.toLowerCase() === c); - } - } - - return str; -} - -module.exports = function () { - var str = [].map.call(arguments, function (str) { - return str.trim(); - }).filter(function (str) { - return str.length; - }).join('-'); - - if (!str.length) { - return ''; - } - - if (str.length === 1) { - return str.toLowerCase(); - } - - if (!(/[_.\- ]+/).test(str)) { - if (str === str.toUpperCase()) { - return str.toLowerCase(); - } - - if (str[0] !== str[0].toLowerCase()) { - return str[0].toLowerCase() + str.slice(1); - } - - return str; - } - - str = preserveCamelCase(str); - - return str - .replace(/^[_.\- ]+/, '') - .toLowerCase() - .replace(/[_.\- ]+(\w|$)/g, function (m, p1) { - return p1.toUpperCase(); - }); -}; diff --git a/node_modules/yargs-parser/node_modules/camelcase/license b/node_modules/yargs-parser/node_modules/camelcase/license deleted file mode 100644 index 654d0bfe9..000000000 --- a/node_modules/yargs-parser/node_modules/camelcase/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) - -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. diff --git a/node_modules/yargs-parser/node_modules/camelcase/package.json b/node_modules/yargs-parser/node_modules/camelcase/package.json deleted file mode 100644 index a404754ee..000000000 --- a/node_modules/yargs-parser/node_modules/camelcase/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "camelcase", - "version": "3.0.0", - "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar", - "license": "MIT", - "repository": "sindresorhus/camelcase", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - }, - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "xo && ava" - }, - "files": [ - "index.js" - ], - "keywords": [ - "camelcase", - "camel-case", - "camel", - "case", - "dash", - "hyphen", - "dot", - "underscore", - "separator", - "string", - "text", - "convert" - ], - "devDependencies": { - "ava": "*", - "xo": "*" - } -} diff --git a/node_modules/yargs-parser/node_modules/camelcase/readme.md b/node_modules/yargs-parser/node_modules/camelcase/readme.md deleted file mode 100644 index 080b2a103..000000000 --- a/node_modules/yargs-parser/node_modules/camelcase/readme.md +++ /dev/null @@ -1,57 +0,0 @@ -# camelcase [](https://travis-ci.org/sindresorhus/camelcase) - -> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar` - - -## Install - -``` -$ npm install --save camelcase -``` - - -## Usage - -```js -const camelCase = require('camelcase'); - -camelCase('foo-bar'); -//=> 'fooBar' - -camelCase('foo_bar'); -//=> 'fooBar' - -camelCase('Foo-Bar'); -//=> 'fooBar' - -camelCase('--foo.bar'); -//=> 'fooBar' - -camelCase('__foo__bar__'); -//=> 'fooBar' - -camelCase('foo bar'); -//=> 'fooBar' - -console.log(process.argv[3]); -//=> '--foo-bar' -camelCase(process.argv[3]); -//=> 'fooBar' - -camelCase('foo', 'bar'); -//=> 'fooBar' - -camelCase('__foo__', '--bar'); -//=> 'fooBar' -``` - - -## Related - -- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module -- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/node_modules/yargs-parser/package.json b/node_modules/yargs-parser/package.json index d025a7ef7..9717e9e07 100644 --- a/node_modules/yargs-parser/package.json +++ b/node_modules/yargs-parser/package.json @@ -1,6 +1,6 @@ { "name": "yargs-parser", - "version": "5.0.0", + "version": "8.0.0", "description": "the mighty option parser used by yargs", "main": "index.js", "scripts": { @@ -29,12 +29,12 @@ "chai": "^3.5.0", "coveralls": "^2.11.12", "mocha": "^3.0.1", - "nyc": "^10.0.0", - "standard": "^8.0.0", + "nyc": "^11.2.1", + "standard": "^10.0.2", "standard-version": "^4.0.0" }, "dependencies": { - "camelcase": "^3.0.0" + "camelcase": "^4.1.0" }, "files": [ "lib", |