Skip to content

Commit 8ffb8ca

Browse files
moonglumFND
authored andcommitted
Ensure boolean CLI arguments are treated as such
... by properly taking advantage of minimist's built-in features previously boolean arguments would swallow subsequent positional arguments (i.e. `--foo bar` erroneously resulted in `{ foo: "bar" }`) note that we're not using minimist's default for the config file because that value is set by `lib/config.js` instead, as we want that default to be the same whether you're using the CLI or the imperative API
1 parent d0a84d2 commit 8ffb8ca

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/cli.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Options:
2525

2626
module.exports = function parseCLI(argv = process.argv.slice(2), help = HELP) {
2727
argv = parseArgs(argv, {
28+
boolean: ["watch", "fingerprint", "sourcemaps", "compact"],
2829
alias: {
2930
c: "config",
3031
w: "watch",
@@ -36,14 +37,12 @@ module.exports = function parseCLI(argv = process.argv.slice(2), help = HELP) {
3637
abort(help, 0);
3738
}
3839

39-
let options = ["watch", "fingerprint", "sourcemaps", "compact"];
40-
options = options.reduce((memo, option) => {
41-
let value = argv[option];
42-
if(value !== undefined) {
43-
memo[option] = value;
44-
}
45-
return memo;
46-
}, {});
40+
let options = {
41+
watch: argv.watch,
42+
fingerprint: argv.fingerprint,
43+
sourcemaps: argv.sourcemaps,
44+
compact: argv.compact
45+
};
4746

4847
if(options.watch && options.fingerprint) { // for convenience
4948
console.error("you might consider disabling fingerprinting in watch " +

0 commit comments

Comments
 (0)