yargs 14.1.0 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/lib/apply-extends.js +1 -1
- package/lib/is-promise.js +1 -1
- package/lib/middleware.js +1 -2
- package/lib/validation.js +21 -28
- package/package.json +2 -2
- package/yargs.js +11 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
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.
|
|
4
4
|
|
|
5
|
+
## [14.2.0](https://github.com/yargs/yargs/compare/v14.1.0...v14.2.0) (2019-10-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* async middleware was called twice ([#1422](https://github.com/yargs/yargs/issues/1422)) ([9a42b63](https://github.com/yargs/yargs/commit/9a42b63))
|
|
11
|
+
* fix promise check to accept any spec conform object ([#1424](https://github.com/yargs/yargs/issues/1424)) ([0be43d2](https://github.com/yargs/yargs/commit/0be43d2))
|
|
12
|
+
* groups were not being maintained for nested commands ([#1430](https://github.com/yargs/yargs/issues/1430)) ([d38650e](https://github.com/yargs/yargs/commit/d38650e))
|
|
13
|
+
* **docs:** broken markdown link ([#1426](https://github.com/yargs/yargs/issues/1426)) ([236e24e](https://github.com/yargs/yargs/commit/236e24e))
|
|
14
|
+
* support merging deeply nested configuration ([#1423](https://github.com/yargs/yargs/issues/1423)) ([bae66fe](https://github.com/yargs/yargs/commit/bae66fe))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **deps:** introduce yargs-parser with support for unknown-options-as-args ([#1440](https://github.com/yargs/yargs/issues/1440)) ([4d21520](https://github.com/yargs/yargs/commit/4d21520))
|
|
20
|
+
|
|
5
21
|
## [14.1.0](https://github.com/yargs/yargs/compare/v14.0.0...v14.1.0) (2019-09-06)
|
|
6
22
|
|
|
7
23
|
|
|
@@ -18,7 +34,6 @@ All notable changes to this project will be documented in this file. See [standa
|
|
|
18
34
|
### Features
|
|
19
35
|
|
|
20
36
|
* make it possible to merge configurations when extending other config. ([#1411](https://github.com/yargs/yargs/issues/1411)) ([5d7ad98](https://github.com/yargs/yargs/commit/5d7ad98))
|
|
21
|
-
* **deps:** yargs-parser with support for collect-unknown-options ([#1421](https://github.com/yargs/yargs/issues/1421)) ([d388a7c](https://github.com/yargs/yargs/commit/d388a7c))
|
|
22
37
|
|
|
23
38
|
## [14.0.0](https://github.com/yargs/yargs/compare/v13.3.0...v14.0.0) (2019-07-30)
|
|
24
39
|
|
package/lib/apply-extends.js
CHANGED
|
@@ -56,7 +56,7 @@ function applyExtends (config, cwd, mergeExtends) {
|
|
|
56
56
|
|
|
57
57
|
defaultConfig = isPath ? JSON.parse(fs.readFileSync(pathToDefault, 'utf8')) : require(config.extends)
|
|
58
58
|
delete config.extends
|
|
59
|
-
defaultConfig = applyExtends(defaultConfig, path.dirname(pathToDefault))
|
|
59
|
+
defaultConfig = applyExtends(defaultConfig, path.dirname(pathToDefault), mergeExtends)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
previouslyVisitedConfigs = []
|
package/lib/is-promise.js
CHANGED
package/lib/middleware.js
CHANGED
|
@@ -40,8 +40,7 @@ function applyMiddleware (argv, yargs, middlewares, beforeValidation) {
|
|
|
40
40
|
const beforeValidationError = new Error('middleware cannot return a promise when applyBeforeValidation is true')
|
|
41
41
|
return middlewares
|
|
42
42
|
.reduce((accumulation, middleware) => {
|
|
43
|
-
if (middleware.applyBeforeValidation !== beforeValidation
|
|
44
|
-
!isPromise(accumulation)) {
|
|
43
|
+
if (middleware.applyBeforeValidation !== beforeValidation) {
|
|
45
44
|
return accumulation
|
|
46
45
|
}
|
|
47
46
|
|
package/lib/validation.js
CHANGED
|
@@ -224,43 +224,36 @@ module.exports = function validation (yargs, usage, y18n) {
|
|
|
224
224
|
return implied
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
function keyExists (argv, val) {
|
|
228
|
+
// convert string '1' to number 1
|
|
229
|
+
let num = Number(val)
|
|
230
|
+
val = isNaN(num) ? val : num
|
|
231
|
+
|
|
232
|
+
if (typeof val === 'number') {
|
|
233
|
+
// check length of argv._
|
|
234
|
+
val = argv._.length >= val
|
|
235
|
+
} else if (val.match(/^--no-.+/)) {
|
|
236
|
+
// check if key/value doesn't exist
|
|
237
|
+
val = val.match(/^--no-(.+)/)[1]
|
|
238
|
+
val = !argv[val]
|
|
239
|
+
} else {
|
|
240
|
+
// check if key/value exists
|
|
241
|
+
val = argv[val]
|
|
242
|
+
}
|
|
243
|
+
return val
|
|
244
|
+
}
|
|
245
|
+
|
|
227
246
|
self.implications = function implications (argv) {
|
|
228
247
|
const implyFail = []
|
|
229
248
|
|
|
230
249
|
Object.keys(implied).forEach((key) => {
|
|
231
250
|
const origKey = key
|
|
232
251
|
;(implied[key] || []).forEach((value) => {
|
|
233
|
-
let num
|
|
234
252
|
let key = origKey
|
|
235
253
|
const origValue = value
|
|
254
|
+
key = keyExists(argv, key)
|
|
255
|
+
value = keyExists(argv, value)
|
|
236
256
|
|
|
237
|
-
// convert string '1' to number 1
|
|
238
|
-
num = Number(key)
|
|
239
|
-
key = isNaN(num) ? key : num
|
|
240
|
-
|
|
241
|
-
if (typeof key === 'number') {
|
|
242
|
-
// check length of argv._
|
|
243
|
-
key = argv._.length >= key
|
|
244
|
-
} else if (key.match(/^--no-.+/)) {
|
|
245
|
-
// check if key doesn't exist
|
|
246
|
-
key = key.match(/^--no-(.+)/)[1]
|
|
247
|
-
key = !argv[key]
|
|
248
|
-
} else {
|
|
249
|
-
// check if key exists
|
|
250
|
-
key = argv[key]
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
num = Number(value)
|
|
254
|
-
value = isNaN(num) ? value : num
|
|
255
|
-
|
|
256
|
-
if (typeof value === 'number') {
|
|
257
|
-
value = argv._.length >= value
|
|
258
|
-
} else if (value.match(/^--no-.+/)) {
|
|
259
|
-
value = value.match(/^--no-(.+)/)[1]
|
|
260
|
-
value = !argv[value]
|
|
261
|
-
} else {
|
|
262
|
-
value = argv[value]
|
|
263
|
-
}
|
|
264
257
|
if (key && !value) {
|
|
265
258
|
implyFail.push(` ${origKey} -> ${origValue}`)
|
|
266
259
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yargs",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "yargs the modern, pirate-themed, successor to optimist.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"contributors": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"string-width": "^3.0.0",
|
|
30
30
|
"which-module": "^2.0.0",
|
|
31
31
|
"y18n": "^4.0.0",
|
|
32
|
-
"yargs-parser": "^
|
|
32
|
+
"yargs-parser": "^15.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"chai": "^4.2.0",
|
package/yargs.js
CHANGED
|
@@ -94,14 +94,17 @@ function Yargs (processArgs, cwd, parentRequire) {
|
|
|
94
94
|
})
|
|
95
95
|
})
|
|
96
96
|
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
// add all groups not set to local to preserved groups
|
|
98
|
+
Object.assign(
|
|
99
|
+
preservedGroups,
|
|
100
|
+
Object.keys(groups).reduce((acc, groupName) => {
|
|
101
|
+
const keys = groups[groupName].filter(key => !(key in localLookup))
|
|
102
|
+
if (keys.length > 0) {
|
|
103
|
+
acc[groupName] = keys
|
|
104
|
+
}
|
|
105
|
+
return acc
|
|
106
|
+
}, {})
|
|
107
|
+
)
|
|
105
108
|
// groups can now be reset
|
|
106
109
|
groups = {}
|
|
107
110
|
|