@@ -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 )
0 commit comments