Allow cli options to be specified in separate definitions

Fix for #963. This allows stuff like `--define a=1 --define b=1` besides only `--define a=1,b=1`
This commit is contained in:
Richard van Velzen
2016-02-08 10:36:28 +01:00
parent cdba43cfa4
commit d5c651a5e5

View File

@@ -499,17 +499,19 @@ function normalize(o) {
} }
} }
function getOptions(x, constants) { function getOptions(flag, constants) {
x = ARGS[x]; var x = ARGS[flag];
if (x == null) return null; if (x == null) return null;
var ret = {}; var ret = {};
if (x !== "") { if (x !== "") {
if (Array.isArray(x)) x = x.map(function (v) { return "(" + v + ")"; }).join(", ");
var ast; var ast;
try { try {
ast = UglifyJS.parse(x, { expression: true }); ast = UglifyJS.parse(x, { expression: true });
} catch(ex) { } catch(ex) {
if (ex instanceof UglifyJS.JS_Parse_Error) { if (ex instanceof UglifyJS.JS_Parse_Error) {
print_error("Error parsing arguments in: " + x); print_error("Error parsing arguments for flag `" + flag + "': " + x);
process.exit(1); process.exit(1);
} }
} }
@@ -529,7 +531,7 @@ function getOptions(x, constants) {
return true; // no descend return true; // no descend
} }
print_error(node.TYPE) print_error(node.TYPE)
print_error("Error parsing arguments in: " + x); print_error("Error parsing arguments for flag `" + flag + "': " + x);
process.exit(1); process.exit(1);
})); }));
} }