@npmcli/config 6.1.6 → 6.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/lib/index.js +23 -9
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -524,21 +524,28 @@ class Config {
|
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
const typeDesc = typeDescription(type)
|
|
527
|
-
const oneOrMore = typeDesc.indexOf(Array) !== -1
|
|
528
527
|
const mustBe = typeDesc
|
|
529
528
|
.filter(m => m !== undefined && m !== Array)
|
|
530
|
-
const
|
|
531
|
-
: mustBe.length > 1 && oneOrMore ? ' one or more of:'
|
|
532
|
-
: mustBe.length > 1 ? ' one of:'
|
|
533
|
-
: ''
|
|
534
|
-
const msg = 'Must be' + oneOf
|
|
529
|
+
const msg = 'Must be' + this.#getOneOfKeywords(mustBe, typeDesc)
|
|
535
530
|
const desc = mustBe.length === 1 ? mustBe[0]
|
|
536
|
-
: mustBe.
|
|
537
|
-
.map(n => typeof n === 'string' ? n : JSON.stringify(n))
|
|
538
|
-
.join(', ')
|
|
531
|
+
: [...new Set(mustBe.map(n => typeof n === 'string' ? n : JSON.stringify(n)))].join(', ')
|
|
539
532
|
log.warn('invalid config', msg, desc)
|
|
540
533
|
}
|
|
541
534
|
|
|
535
|
+
#getOneOfKeywords (mustBe, typeDesc) {
|
|
536
|
+
let keyword
|
|
537
|
+
if (mustBe.length === 1 && typeDesc.includes(Array)) {
|
|
538
|
+
keyword = ' one or more'
|
|
539
|
+
} else if (mustBe.length > 1 && typeDesc.includes(Array)) {
|
|
540
|
+
keyword = ' one or more of:'
|
|
541
|
+
} else if (mustBe.length > 1) {
|
|
542
|
+
keyword = ' one of:'
|
|
543
|
+
} else {
|
|
544
|
+
keyword = ''
|
|
545
|
+
}
|
|
546
|
+
return keyword
|
|
547
|
+
}
|
|
548
|
+
|
|
542
549
|
#loadObject (obj, where, source, er = null) {
|
|
543
550
|
// obj is the raw data read from the file
|
|
544
551
|
const conf = this.data.get(where)
|
|
@@ -568,6 +575,13 @@ class Config {
|
|
|
568
575
|
const v = this.parseField(value, k)
|
|
569
576
|
if (where !== 'default') {
|
|
570
577
|
this.#checkDeprecated(k, where, obj, [key, value])
|
|
578
|
+
if (this.definitions[key]?.exclusive) {
|
|
579
|
+
for (const exclusive of this.definitions[key].exclusive) {
|
|
580
|
+
if (!this.isDefault(exclusive)) {
|
|
581
|
+
throw new TypeError(`--${key} can not be provided when using --${exclusive}`)
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
571
585
|
}
|
|
572
586
|
conf.data[k] = v
|
|
573
587
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/config",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"bin/",
|
|
6
6
|
"lib/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@npmcli/eslint-config": "^4.0.0",
|
|
36
|
-
"@npmcli/template-oss": "4.
|
|
36
|
+
"@npmcli/template-oss": "4.14.1",
|
|
37
37
|
"tap": "^16.3.4"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"templateOSS": {
|
|
52
52
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
53
|
-
"version": "4.
|
|
53
|
+
"version": "4.14.1"
|
|
54
54
|
}
|
|
55
55
|
}
|