Fix reading arguments

i.e. read `-c unsafe,unsafe-comps` as `-c unsafe=true,unsafe_comps=true`
This commit is contained in:
Mihai Bazon
2013-10-29 14:01:26 +02:00
parent a14c6b6574
commit 7cf79c302b

View File

@@ -381,7 +381,7 @@ function getOptions(x, constants) {
if (x !== true) { if (x !== true) {
var ast; var ast;
try { try {
ast = UglifyJS.parse(x); ast = UglifyJS.parse(x, { expression: true });
} catch(ex) { } catch(ex) {
if (ex instanceof UglifyJS.JS_Parse_Error) { if (ex instanceof UglifyJS.JS_Parse_Error) {
sys.error("Error parsing arguments in: " + x); sys.error("Error parsing arguments in: " + x);
@@ -389,8 +389,6 @@ function getOptions(x, constants) {
} }
} }
ast.walk(new UglifyJS.TreeWalker(function(node){ ast.walk(new UglifyJS.TreeWalker(function(node){
if (node instanceof UglifyJS.AST_Toplevel) return; // descend
if (node instanceof UglifyJS.AST_SimpleStatement) return; // descend
if (node instanceof UglifyJS.AST_Seq) return; // descend if (node instanceof UglifyJS.AST_Seq) return; // descend
if (node instanceof UglifyJS.AST_Assign) { if (node instanceof UglifyJS.AST_Assign) {
var name = node.left.print_to_string({ beautify: false }).replace(/-/g, "_"); var name = node.left.print_to_string({ beautify: false }).replace(/-/g, "_");
@@ -400,6 +398,11 @@ function getOptions(x, constants) {
ret[name] = value; ret[name] = value;
return true; // no descend return true; // no descend
} }
if (node instanceof UglifyJS.AST_Symbol || node instanceof UglifyJS.AST_Binary) {
var name = node.print_to_string({ beautify: false }).replace(/-/g, "_");
ret[name] = true;
return true; // no descend
}
sys.error(node.TYPE) sys.error(node.TYPE)
sys.error("Error parsing arguments in: " + x); sys.error("Error parsing arguments in: " + x);
process.exit(1); process.exit(1);