Add --noerr to turn off argument name checking
authorMihai Bazon <mihai@bazon.net>
Thu, 28 Nov 2013 11:15:01 +0000 (13:15 +0200)
committerMihai Bazon <mihai@bazon.net>
Thu, 28 Nov 2013 11:15:01 +0000 (13:15 +0200)
for now only used for keys passed to `-c` or `-b`.

bin/uglifyjs
lib/utils.js

index 4160171..9e8573e 100755 (executable)
@@ -62,6 +62,7 @@ You need to pass an argument to this option to specify the name that your module
     .describe("lint", "Display some scope warnings")
     .describe("v", "Verbose")
     .describe("V", "Print version number and exit.")
+    .describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.")
 
     .alias("p", "prefix")
     .alias("o", "output")
@@ -96,6 +97,7 @@ You need to pass an argument to this option to specify the name that your module
     .boolean("spidermonkey")
     .boolean("lint")
     .boolean("V")
+    .boolean("noerr")
 
     .wrap(80)
 
@@ -104,6 +106,12 @@ You need to pass an argument to this option to specify the name that your module
 
 normalize(ARGS);
 
+if (ARGS.noerr) {
+    UglifyJS.DefaultsError.croak = function(msg, defs) {
+        sys.error("WARN: " + msg);
+    };
+}
+
 if (ARGS.version || ARGS.V) {
     var json = require("../package.json");
     sys.puts(json.name + ' ' + json.version);
index 73964a0..fa24663 100644 (file)
@@ -86,12 +86,16 @@ function DefaultsError(msg, defs) {
     this.defs = defs;
 };
 
+DefaultsError.croak = function(msg, defs) {
+    throw new DefaultsError(msg, defs);
+};
+
 function defaults(args, defs, croak) {
     if (args === true)
         args = {};
     var ret = args || {};
     if (croak) for (var i in ret) if (ret.hasOwnProperty(i) && !defs.hasOwnProperty(i))
-        throw new DefaultsError("`" + i + "` is not a supported option", defs);
+        DefaultsError.croak("`" + i + "` is not a supported option", defs);
     for (var i in defs) if (defs.hasOwnProperty(i)) {
         ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i];
     }