aboutsummaryrefslogtreecommitdiff
path: root/node_modules/yargs-parser
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/yargs-parser')
-rw-r--r--node_modules/yargs-parser/CHANGELOG.md21
-rw-r--r--node_modules/yargs-parser/README.md8
-rw-r--r--node_modules/yargs-parser/index.js54
-rw-r--r--node_modules/yargs-parser/lib/tokenize-arg-string.js2
-rw-r--r--node_modules/yargs-parser/package.json6
5 files changed, 73 insertions, 18 deletions
diff --git a/node_modules/yargs-parser/CHANGELOG.md b/node_modules/yargs-parser/CHANGELOG.md
index f9e7c6237..6d237f614 100644
--- a/node_modules/yargs-parser/CHANGELOG.md
+++ b/node_modules/yargs-parser/CHANGELOG.md
@@ -2,6 +2,27 @@
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.1.0"></a>
+# [8.1.0](https://github.com/yargs/yargs-parser/compare/v8.0.0...v8.1.0) (2017-12-20)
+
+
+### Bug Fixes
+
+* allow null config values ([#108](https://github.com/yargs/yargs-parser/issues/108)) ([d8b14f9](https://github.com/yargs/yargs-parser/commit/d8b14f9))
+* ensure consistent parsing of dot-notation arguments ([#102](https://github.com/yargs/yargs-parser/issues/102)) ([c9bd79c](https://github.com/yargs/yargs-parser/commit/c9bd79c))
+* implement [@antoniom](https://github.com/antoniom)'s fix for camel-case expansion ([3087e1d](https://github.com/yargs/yargs-parser/commit/3087e1d))
+* only run coercion functions once, despite aliases. ([#76](https://github.com/yargs/yargs-parser/issues/76)) ([#103](https://github.com/yargs/yargs-parser/issues/103)) ([507aaef](https://github.com/yargs/yargs-parser/commit/507aaef))
+* scientific notation circumvented bounds check ([#110](https://github.com/yargs/yargs-parser/issues/110)) ([3571f57](https://github.com/yargs/yargs-parser/commit/3571f57))
+* tokenizer should ignore spaces at the beginning of the argString ([#106](https://github.com/yargs/yargs-parser/issues/106)) ([f34ead9](https://github.com/yargs/yargs-parser/commit/f34ead9))
+
+
+### Features
+
+* make combining arrays a configurable option ([#111](https://github.com/yargs/yargs-parser/issues/111)) ([c8bf536](https://github.com/yargs/yargs-parser/commit/c8bf536))
+* merge array from arguments with array from config ([#83](https://github.com/yargs/yargs-parser/issues/83)) ([806ddd6](https://github.com/yargs/yargs-parser/commit/806ddd6))
+
+
+
<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)
diff --git a/node_modules/yargs-parser/README.md b/node_modules/yargs-parser/README.md
index a368e632b..6d6d0d4c9 100644
--- a/node_modules/yargs-parser/README.md
+++ b/node_modules/yargs-parser/README.md
@@ -212,6 +212,14 @@ node example.js --no-foo
{ _: [], "no-foo": true }
```
+### combine arrays
+
+* default: `false`
+* key: `combine-arrays`
+
+Should arrays be combined when provided by both command line arguments and
+a configuration file.
+
### duplicate arguments array
* default: `true`
diff --git a/node_modules/yargs-parser/index.js b/node_modules/yargs-parser/index.js
index c06d93707..1d3e6b9bc 100644
--- a/node_modules/yargs-parser/index.js
+++ b/node_modules/yargs-parser/index.js
@@ -19,7 +19,8 @@ function parse (args, opts) {
'negation-prefix': 'no-',
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': true,
- 'populate--': false
+ 'populate--': false,
+ 'combine-arrays': false
}, opts.configuration)
var defaults = opts.default || {}
var configObjects = opts.configObjects || []
@@ -425,7 +426,9 @@ function parse (args, opts) {
function maybeCoerceNumber (key, value) {
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.coercions)) {
- const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (Number.isSafeInteger(parseInt(value)))
+ const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && (
+ Number.isSafeInteger(Math.floor(value))
+ )
if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) value = Number(value)
}
return value
@@ -479,13 +482,13 @@ function parse (args, opts) {
// if the value is an inner object and we have dot-notation
// enabled, treat inner objects in config the same as
// heavily nested dot notations (foo.bar.apple).
- if (typeof value === 'object' && !Array.isArray(value) && configuration['dot-notation']) {
+ if (typeof value === 'object' && value !== null && !Array.isArray(value) && configuration['dot-notation']) {
// if the value is an object but not an array, check nested object
setConfigObject(value, fullKey)
} else {
// setting arguments via CLI takes precedence over
// values within the config file.
- if (!hasKey(argv, fullKey.split('.')) || (flags.defaulted[fullKey])) {
+ if (!hasKey(argv, fullKey.split('.')) || (flags.defaulted[fullKey]) || (flags.arrays[fullKey] && configuration['combine-arrays'])) {
setArg(fullKey, value)
}
}
@@ -523,13 +526,19 @@ function parse (args, opts) {
function applyCoercions (argv) {
var coerce
+ var applied = {}
Object.keys(argv).forEach(function (key) {
- coerce = checkAllAliases(key, flags.coercions)
- if (typeof coerce === 'function') {
- try {
- argv[key] = coerce(argv[key])
- } catch (err) {
- error = err
+ if (!applied.hasOwnProperty(key)) { // If we haven't already coerced this option via one of its aliases
+ coerce = checkAllAliases(key, flags.coercions)
+ if (typeof coerce === 'function') {
+ try {
+ var value = coerce(argv[key])
+ ;([].concat(flags.aliases[key] || [], key)).forEach(ali => {
+ applied[ali] = argv[ali] = value
+ })
+ } catch (err) {
+ error = err
+ }
}
}
})
@@ -568,9 +577,24 @@ function parse (args, opts) {
if (!configuration['dot-notation']) keys = [keys.join('.')]
- keys.slice(0, -1).forEach(function (key) {
- if (o[key] === undefined) o[key] = {}
- o = o[key]
+ keys.slice(0, -1).forEach(function (key, index) {
+ if (typeof o === 'object' && o[key] === undefined) {
+ o[key] = {}
+ }
+
+ if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
+ // ensure that o[key] is an array, and that the last item is an empty object.
+ if (Array.isArray(o[key])) {
+ o[key].push({})
+ } else {
+ o[key] = [o[key], {}]
+ }
+
+ // we want to update the empty object at the end of the o[key] array, so set o to that object
+ o = o[key][o[key].length - 1]
+ } else {
+ o = o[key]
+ }
})
var key = keys[keys.length - 1]
@@ -612,10 +636,10 @@ function parse (args, opts) {
flags.aliases[key].concat(key).forEach(function (x) {
if (/-/.test(x) && configuration['camel-case-expansion']) {
var c = camelCase(x)
- if (flags.aliases[key].indexOf(c) === -1) {
+ if (c !== key && flags.aliases[key].indexOf(c) === -1) {
flags.aliases[key].push(c)
+ newAliases[c] = true
}
- newAliases[c] = true
}
})
flags.aliases[key].forEach(function (x) {
diff --git a/node_modules/yargs-parser/lib/tokenize-arg-string.js b/node_modules/yargs-parser/lib/tokenize-arg-string.js
index 70154425c..6c8d23ef2 100644
--- a/node_modules/yargs-parser/lib/tokenize-arg-string.js
+++ b/node_modules/yargs-parser/lib/tokenize-arg-string.js
@@ -2,6 +2,8 @@
module.exports = function (argString) {
if (Array.isArray(argString)) return argString
+ argString = argString.trim()
+
var i = 0
var prevC = null
var c = null
diff --git a/node_modules/yargs-parser/package.json b/node_modules/yargs-parser/package.json
index 9717e9e07..0c940b125 100644
--- a/node_modules/yargs-parser/package.json
+++ b/node_modules/yargs-parser/package.json
@@ -1,6 +1,6 @@
{
"name": "yargs-parser",
- "version": "8.0.0",
+ "version": "8.1.0",
"description": "the mighty option parser used by yargs",
"main": "index.js",
"scripts": {
@@ -29,9 +29,9 @@
"chai": "^3.5.0",
"coveralls": "^2.11.12",
"mocha": "^3.0.1",
- "nyc": "^11.2.1",
+ "nyc": "^11.4.1",
"standard": "^10.0.2",
- "standard-version": "^4.0.0"
+ "standard-version": "^4.3.0-candidate.0"
},
"dependencies": {
"camelcase": "^4.1.0"