aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-09-13 19:45:16 +0300
committerMihai Bazon <mihai@bazon.net>2012-09-13 19:45:16 +0300
commit93b973c99dd25aeff66ff31f2881e9ce252eaac6 (patch)
tree7e8dba5b7348d76a91cd99248a8e4401b9ad0085 /bin
parentd72c1d1293487b7e775d0a248f8c9c848b01502c (diff)
downloadtracifyjs-93b973c99dd25aeff66ff31f2881e9ce252eaac6.tar.gz
tracifyjs-93b973c99dd25aeff66ff31f2881e9ce252eaac6.zip
added -m and -c options
Diffstat (limited to 'bin')
-rwxr-xr-xbin/uglifyjs228
1 files changed, 23 insertions, 5 deletions
diff --git a/bin/uglifyjs2 b/bin/uglifyjs2
index 60bbc0fb..fd57a662 100755
--- a/bin/uglifyjs2
+++ b/bin/uglifyjs2
@@ -17,28 +17,44 @@ Use a single dash to read input from the standard input.\
.describe("stats", "Display operations run time on STDERR")
.describe("v", "Verbose")
.describe("b", "Beautify output")
+ .describe("m", "Don't mangle names")
+ .describe("c", "Compressor options")
.alias("p", "prefix")
.alias("o", "output")
.alias("v", "verbose")
.alias("b", "beautify")
+ .alias("c", "options")
.boolean("b")
.boolean("v")
.boolean("stats")
+ .boolean("m")
.argv
;
-for (var i in ARGS) if (ARGS.hasOwnProperty(i) && /-/.test(i)) {
- ARGS[i.replace(/-/g, "_")] = ARGS[i];
+function normalize(o) {
+ for (var i in o) if (o.hasOwnProperty(i) && /-/.test(i)) {
+ o[i.replace(/-/g, "_")] = o[i];
+ }
}
+normalize(ARGS);
+
if (ARGS.h || ARGS.help) {
sys.puts(optimist.help());
process.exit(0);
}
+var COMPRESSOR_OPTIONS = {};
+if (ARGS.c) {
+ ARGS.c.replace(/^\s+|\s+$/g).split(/\s*,+\s*/).forEach(function(opt){
+ var a = opt.split(/\s*=\s*/);
+ COMPRESSOR_OPTIONS[a[0]] = new Function("return(" + a[1] + ")")();
+ });
+}
+
var files = ARGS._.slice();
if (files.length == 0)
@@ -117,7 +133,7 @@ function do_file_1(file) {
ast.figure_out_scope();
});
time_it("squeeze", function(){
- var compressor = UglifyJS.Compressor({});
+ var compressor = UglifyJS.Compressor(COMPRESSOR_OPTIONS);
ast = ast.squeeze(compressor);
});
ast.filename = file;
@@ -127,7 +143,9 @@ function do_file_1(file) {
function do_file_2(ast) {
time_it("scope", function(){
ast.figure_out_scope();
- ast.compute_char_frequency();
+ if (!ARGS.m) {
+ ast.compute_char_frequency();
+ }
});
return ast;
}
@@ -137,7 +155,7 @@ function do_file_3(ast) {
// if (ARGS.v) {
// sys.error("Mangling/generating " + file);
// }
- time_it("mangle", function(){
+ if (!ARGS.m) time_it("mangle", function(){
ast.mangle_names();
});
time_it("generate", function(){