Skip to content

Commit 71e79d6

Browse files
committed
config: Fix a theme item parsing todo
Returning all invalid theme value errors at once
1 parent a282d36 commit 71e79d6

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

lib/config.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function validatePlatform(os) {
6262
}
6363

6464
function validateThemeItem(field, key) {
65-
let validValues = ['',
65+
const validValues = ['',
6666
'reset',
6767
'bold',
6868
'dim',
@@ -88,16 +88,17 @@ function validateThemeItem(field, key) {
8888
'bgCyan',
8989
'bgWhite'
9090
];
91-
// TODO: change this to return all errors in a field
92-
for (let item in field) {
93-
if (field.hasOwnProperty(item)) {
94-
let tokens = field[item].replace(/\s+/g, '').split(',');
95-
for (let i = 0; i < tokens.length; i++) {
96-
if (validValues.indexOf(tokens[i]) < 0) {
97-
return 'Invalid theme value : ' + tokens[i] + ' in ' + key + ' theme';
98-
}
91+
let errMsg = [];
92+
for (let fieldKey of Object.keys(field)) {
93+
let tokens = field[fieldKey].replace(/\s+/g, '').split(',');
94+
tokens.forEach((token) => {
95+
if (validValues.indexOf(token) < 0) {
96+
errMsg.push('Invalid theme value : ' + token + ' in ' + key + ' theme');
9997
}
100-
}
98+
});
10199
}
102-
return null;
100+
if (errMsg.length === 0) {
101+
return null;
102+
}
103+
return errMsg.join('\n');
103104
}

0 commit comments

Comments
 (0)