@npmcli/config 6.1.6 → 6.1.7

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.
Files changed (2) hide show
  1. package/lib/index.js +16 -9
  2. 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 oneOf = mustBe.length === 1 && oneOrMore ? ' one or more'
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.filter(m => m !== Array)
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/config",
3
- "version": "6.1.6",
3
+ "version": "6.1.7",
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.12.1",
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.12.1"
53
+ "version": "4.14.1"
54
54
  }
55
55
  }