Skip to content

Commit 5a2f7ea

Browse files
committed
fix: cli --watch-poll not accept number correctly
The document say "--watch-poll" option can determine "The polling interval for watching (also enable polling)". But the previous implement only accept boolean value and no way to set the interval. This patch try to fix this problem by allow number input like this: "--watch-poll=100". This patch also try to keep the original behavior not be changed as much as possible. So "--watch-poll" and "--watch-poll=true" are still acceptable (enable the polling ability). But still has one incompatible change: original "--watch-poll=" mean disable polling but after this fix it mean enable polling. It's due to yargs can not differentiate the different between "--watch-poll" and "--watch-poll=" when using string type option. So no way to workaround for this problem.
1 parent 990563f commit 5a2f7ea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

bin/config-yargs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ module.exports = function(yargs) {
172172
requiresArg: true
173173
},
174174
"watch-poll": {
175-
type: "boolean",
175+
type: "string",
176176
describe: "The polling interval for watching (also enable polling)",
177177
group: ADVANCED_GROUP
178178
},

bin/convert-argv.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ module.exports = function(yargs, argv, convertOptions) {
166166
options.watchOptions.aggregateTimeout = +argv["watch-aggregate-timeout"];
167167
}
168168

169-
if(argv["watch-poll"]) {
169+
if(typeof argv["watch-poll"] !== undefined) {
170170
options.watchOptions = options.watchOptions || {};
171-
if(typeof argv["watch-poll"] !== "boolean")
172-
options.watchOptions.poll = +argv["watch-poll"];
173-
else
171+
if(argv["watch-poll"] === "true" || argv["watch-poll"] === "")
174172
options.watchOptions.poll = true;
173+
else if(!isNaN(argv["watch-poll"]))
174+
options.watchOptions.poll = +argv["watch-poll"];
175175
}
176176

177177
if(argv["watch-stdin"]) {

0 commit comments

Comments
 (0)