Skip to content

Commit 353ec6b

Browse files
committed
fix(options): validate the timeout option's value
The whitelist entry that skipped timeout's validation was a leftover of the mocha-era pass-through list; timeout is a real declared option (debug and device commands) and only coincidentally shared the name. With the entry gone, a bare --timeout gets the same non-empty-value staging warning as every other string option.
1 parent 0549b1c commit 353ec6b

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎lib/options.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Options {
1515
private static DASHED_OPTION_REGEX = /(.+?)([A-Z])(.*)/;
1616
private static NONDASHED_OPTION_REGEX = /(.+?)[-]([a-zA-Z])(.*)/;
1717

18-
private optionsWhiteList = ["timeout", "_", "$0"]; // These options shouldn't be validated
18+
private optionsWhiteList = ["_", "$0"]; // yargs artifacts, not options
1919
private globalOptions: IDictionary<IDashedOption> = {
2020
log: { type: OptionType.String, hasSensitiveValue: false },
2121
verbose: { type: OptionType.Boolean, hasSensitiveValue: false },

‎test/options.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ describe("options", () => {
137137
assert.isTrue(isExecutionStopped);
138138
});
139139

140+
it("breaks execution when the timeout option has no value", () => {
141+
process.argv.push("--timeout");
142+
const options = createOptions(testInjector);
143+
options.validateOptions();
144+
process.argv.pop();
145+
assert.isTrue(isExecutionStopped);
146+
});
147+
148+
it("does not break execution when the timeout option has a value", () => {
149+
process.argv.push("--timeout");
150+
process.argv.push("500");
151+
const options = createOptions(testInjector);
152+
options.validateOptions();
153+
process.argv.pop();
154+
process.argv.pop();
155+
assert.isFalse(isExecutionStopped);
156+
});
157+
140158
it("breaks execution when valid option has value with spaces only", () => {
141159
process.argv.push("--path");
142160
process.argv.push(" ");

0 commit comments

Comments
 (0)