Skip to content

Commit 9eefec2

Browse files
committed
Merge pull request #568 from jawshooah/fix-json-options
More lenient config files syntax
2 parents 5436a1e + 3b9fc99 commit 9eefec2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/cli/common.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,28 @@ function cli(api) {
306306
function readConfigData(config) {
307307
var data = readConfigFile(config),
308308
json,
309+
optionName,
310+
optionValue,
311+
args,
309312
options = {};
310313
if (data) {
311314
if (data.charAt(0) === "{") {
312315
try {
313316
json = JSON.parse(data);
314317
data = "";
315-
for (var optionName in json) {
318+
for (optionName in json) {
316319
if (json.hasOwnProperty(optionName)) {
317-
data += "--" + optionName + "=" + json[optionName].join();
320+
optionValue = json[optionName];
321+
if (Array.isArray(optionValue)) {
322+
optionValue = optionValue.join(",");
323+
}
324+
data += "--" + optionName + "=" + optionValue;
318325
}
319326
}
320327
} catch (e) {}
321328
}
322-
options = processArguments(data.split(/[\s\n\r]+/m));
329+
args = data.replace(/\s+/g,"").split(/(?=--)/);
330+
options = processArguments(args);
323331
}
324332

325333
return options;

0 commit comments

Comments
 (0)