From 7cf79c302b61ebd07c33aabee929dfb8666cba56 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Tue, 29 Oct 2013 14:01:26 +0200 Subject: [PATCH] Fix reading arguments i.e. read `-c unsafe,unsafe-comps` as `-c unsafe=true,unsafe_comps=true` --- bin/uglifyjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/uglifyjs b/bin/uglifyjs index 9bdb8ea7..4160171d 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -381,7 +381,7 @@ function getOptions(x, constants) { if (x !== true) { var ast; try { - ast = UglifyJS.parse(x); + ast = UglifyJS.parse(x, { expression: true }); } catch(ex) { if (ex instanceof UglifyJS.JS_Parse_Error) { sys.error("Error parsing arguments in: " + x); @@ -389,8 +389,6 @@ function getOptions(x, constants) { } } 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_Assign) { var name = node.left.print_to_string({ beautify: false }).replace(/-/g, "_"); @@ -400,6 +398,11 @@ function getOptions(x, constants) { ret[name] = value; 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("Error parsing arguments in: " + x); process.exit(1); -- 2.34.1