improve CLI usability (#2016)

Report supported options upon invalid option syntax.

fixes #1883
This commit is contained in:
Alex Lam S.L
2017-05-28 04:09:40 +08:00
committed by GitHub
parent 79131cd647
commit fec14379f6
2 changed files with 10 additions and 1 deletions

View File

@@ -351,7 +351,7 @@ function parse_js(flag, constants) {
} }
})); }));
} catch(ex) { } catch(ex) {
fatal("Error parsing arguments for '" + flag + "': " + value); options[value] = null;
} }
return options; return options;
} }

View File

@@ -537,4 +537,13 @@ describe("bin/uglifyjs", function () {
done(); 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();
});
});
}); });