Skip to content

Commit 1e0db9c

Browse files
committedJan 4, 2020
Rename defValue to default
1 parent 0d250ad commit 1e0db9c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed
 

‎lib/command.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ module.exports = class Command {
163163
createOptionValues(values) {
164164
const storage = Object.create(null);
165165

166-
for (const { name, normalize, defValue } of this.getOptions()) {
167-
if (typeof defValue !== 'undefined') {
168-
storage[name] = normalize(defValue);
166+
for (const { name, normalize, default: value } of this.getOptions()) {
167+
if (typeof value !== 'undefined') {
168+
storage[name] = normalize(value);
169169
}
170170
}
171171

‎lib/option.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const self = value => value;
66
module.exports = class Option {
77
static normalizeOptions(opt1, opt2) {
88
const raw = typeof opt1 === 'function'
9-
? { normalize: opt1, value: opt2 }
9+
? { normalize: opt1, default: opt2 }
1010
: opt1 && typeof opt1 === 'object'
1111
? opt1
12-
: { value: opt1 };
12+
: { default: opt1 };
1313

1414
return {
15-
defValue: !ensureFunction(raw.action) ? raw.value : undefined,
15+
default: !ensureFunction(raw.action) ? raw.default : undefined,
1616
normalize: ensureFunction(raw.normalize, self),
1717
shortcut: ensureFunction(raw.shortcut),
1818
action: ensureFunction(raw.action),
@@ -58,7 +58,7 @@ module.exports = class Option {
5858

5959
// ignore defValue from config for boolean options
6060
if (typeof defValue === 'boolean' && !this.action) {
61-
this.defValue = defValue;
61+
this.default = defValue;
6262
}
6363
}
6464

‎lib/parse-argv.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function consumeOptionParams(option, rawOptions, argv, index, suggestPoint) {
3636

3737
value = option.params.maxCount === 1 ? tokens[0] : tokens;
3838
} else {
39-
value = !option.defValue;
39+
value = !option.default;
4040
}
4141

4242
rawOptions.push({
@@ -115,7 +115,7 @@ module.exports = function parseArgv(command, argv, context, suggestMode) {
115115

116116
rawOptions.push({
117117
option,
118-
value: !option.defValue
118+
value: !option.default
119119
});
120120
}
121121
}

‎test/command-createOptionValues.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('createOptionValues()', function() {
7272
const command = cli.command()
7373
.option('--foo <value>', '', Number)
7474
.option('--bar [value]')
75-
.option('--with-default [x]', '', { value: 'default' })
75+
.option('--with-default [x]', '', { default: 'default' })
7676
.option('--bool');
7777

7878
assert.deepStrictEqual(

0 commit comments

Comments
 (0)
Please sign in to comment.