aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/uglifyjs25
-rw-r--r--lib/utils.js8
-rw-r--r--test/ufuzz/index.js11
-rw-r--r--tools/node.js4
4 files changed, 34 insertions, 14 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs
index 4f84d387..2b02df03 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -23,12 +23,29 @@ program.parse = undefined;
if (process.argv.indexOf("ast") >= 0) program.helpInformation = UglifyJS.describe_ast;
else if (process.argv.indexOf("options") >= 0) program.helpInformation = function() {
var text = [];
+ var toplevels = [];
+ var padding = "";
var options = UglifyJS.default_options();
- for (var option in options) {
- text.push("--" + (option == "output" ? "beautify" : option == "sourceMap" ? "source-map" : option) + " options:");
- text.push(format_object(options[option]));
- text.push("");
+ for (var name in options) {
+ var option = options[name];
+ if (option && typeof option == "object") {
+ text.push("--" + ({
+ output: "beautify",
+ sourceMap: "source-map",
+ }[name] || name) + " options:");
+ text.push(format_object(option));
+ text.push("");
+ } else {
+ if (padding.length < name.length) padding = Array(name.length + 1).join(" ");
+ toplevels.push([ {
+ keep_fnames: "keep-fnames",
+ nameCache: "name-cache",
+ }[name] || name, option ]);
+ }
}
+ toplevels.forEach(function(tokens) {
+ text.push("--" + tokens[0] + padding.slice(tokens[0].length - 2) + tokens[1]);
+ });
return text.join("\n");
};
program.option("-p, --parse <options>", "Specify parser options.", parse_js());
diff --git a/lib/utils.js b/lib/utils.js
index 7932e05f..32d410a1 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -87,9 +87,11 @@ DefaultsError.prototype.name = "DefaultsError";
configure_error_stack(DefaultsError);
function defaults(args, defs, croak) {
- for (var i in args) if (HOP(args, i)) {
- if (croak && !HOP(defs, i)) throw new DefaultsError("`" + i + "` is not a supported option", defs);
- defs[i] = args[i];
+ if (croak) for (var i in args) {
+ if (HOP(args, i) && !HOP(defs, i)) throw new DefaultsError("`" + i + "` is not a supported option", defs);
+ }
+ for (var i in args) {
+ if (HOP(args, i)) defs[i] = args[i];
}
return defs;
}
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index e56408d9..908fabd1 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -1045,10 +1045,8 @@ function log_suspects(minify_options, component) {
}
function log_suspects_global(options) {
- var o = {};
- UglifyJS.minify("", o);
- var suspects = Object.keys(o).filter(function(component) {
- return typeof o[component] != "object";
+ var suspects = Object.keys(default_options).filter(function(component) {
+ return typeof default_options[component] != "object";
}).filter(function(component) {
var m = JSON.parse(options);
m[component] = false;
@@ -1115,7 +1113,10 @@ function log(options) {
errorln(JSON.stringify(JSON.parse(options), null, 2));
errorln();
if (!ok && typeof uglify_code == "string") {
- Object.keys(default_options).forEach(log_suspects.bind(null, JSON.parse(options)));
+ Object.keys(default_options).filter(function(component) {
+ var defs = default_options[component];
+ return defs && typeof defs == "object";
+ }).forEach(log_suspects.bind(null, JSON.parse(options)));
log_suspects_global(options);
errorln("!!!!!! Failed... round " + round);
}
diff --git a/tools/node.js b/tools/node.js
index ef05f571..631a2930 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -66,8 +66,8 @@ function infer_options(options) {
}
exports.default_options = function() {
- var defs = {};
- Object.keys(infer_options({ 0: 0 })).forEach(function(component) {
+ var defs = infer_options({ 0: 0 });
+ Object.keys(defs).forEach(function(component) {
var options = {};
options[component] = { 0: 0 };
if (options = infer_options(options)) {