From: Alex Lam S.L Date: Sat, 27 May 2017 20:09:40 +0000 (+0800) Subject: improve CLI usability (#2016) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=fec14379f6bae209484d75ba1db5c6b5ee37ae5a;p=UglifyJS.git improve CLI usability (#2016) Report supported options upon invalid option syntax. fixes #1883 --- diff --git a/bin/uglifyjs b/bin/uglifyjs index 8ea7d16b..158dc571 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -351,7 +351,7 @@ function parse_js(flag, constants) { } })); } catch(ex) { - fatal("Error parsing arguments for '" + flag + "': " + value); + options[value] = null; } return options; } diff --git a/test/mocha/cli.js b/test/mocha/cli.js index 565b6069..4234f2fb 100644 --- a/test/mocha/cli.js +++ b/test/mocha/cli.js @@ -537,4 +537,13 @@ describe("bin/uglifyjs", function () { done(); }); }); + it("Should print supported options on invalid option syntax", function(done) { + var command = uglifyjscmd + " test/input/comments/filter.js -b ascii-only"; + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.ok(/^Supported options:\n\{[^}]+}\nERROR: `ascii-only` is not a supported option/.test(stderr), stderr); + done(); + }); + }); });