aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMihai Bazon <mihai.bazon@gmail.com>2015-03-18 11:53:17 +0200
committerMihai Bazon <mihai.bazon@gmail.com>2015-03-18 11:53:17 +0200
commit3ef092332b1e7c9bf1d17038601a33bd742dd753 (patch)
tree642eaa5395124cbb7f27955936455c943db341e4 /bin
parent540c19792f813e38a815ff1bd2228ac0eca9e502 (diff)
downloadtracifyjs-3ef092332b1e7c9bf1d17038601a33bd742dd753.tar.gz
tracifyjs-3ef092332b1e7c9bf1d17038601a33bd742dd753.zip
Support multiple --reserved-file args
Diffstat (limited to 'bin')
-rwxr-xr-xbin/uglifyjs25
1 files changed, 12 insertions, 13 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs
index e1deaf5e..281ac175 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -94,8 +94,8 @@ You need to pass an argument to this option to specify the name that your module
.string("comments")
.string("wrap")
.string("p")
- .string("reserved-file")
.string("name-cache")
+ .array("reserved-file")
.boolean("expr")
.boolean("source-map-include-sources")
@@ -150,6 +150,11 @@ if (ARGS.acorn) {
var COMPRESS = getOptions("c", true);
var MANGLE = getOptions("m", true);
var BEAUTIFY = getOptions("b", true);
+var RESERVED = null;
+
+if (ARGS.reserved_file) ARGS.reserved_file.forEach(function(filename){
+ RESERVED = UglifyJS.readReservedFile(filename, RESERVED);
+});
if (ARGS.d) {
if (COMPRESS) COMPRESS.global_defs = getOptions("d");
@@ -159,16 +164,10 @@ if (ARGS.r) {
if (MANGLE) MANGLE.except = ARGS.r.replace(/^\s+|\s+$/g).split(/\s*,+\s*/);
}
-var RESERVED = null;
-if (ARGS.reserved_file) (function(){
- var data = fs.readFileSync(ARGS.reserved_file, "utf8");
- RESERVED = data = JSON.parse(data);
- if (data.vars) {
- MANGLE.except = MANGLE.except
- ? MANGLE.except.concat(data.vars)
- : data.vars;
- }
-})();
+if (RESERVED && MANGLE) {
+ if (!MANGLE.except) MANGLE.except = RESERVED.vars;
+ else MANGLE.except = MANGLE.except.concat(RESERVED.vars);
+}
function readNameCache(key) {
return UglifyJS.readNameCache(ARGS.name_cache, key);
@@ -457,9 +456,9 @@ function normalize(o) {
function getOptions(x, constants) {
x = ARGS[x];
- if (!x) return null;
+ if (x == null) return null;
var ret = {};
- if (x !== true) {
+ if (x !== "") {
var ast;
try {
ast = UglifyJS.parse(x, { expression: true });