Skip to content

Commit 2c551bb

Browse files
bricasJohn Doherty
authored andcommitted
add custom coerce function for parsing integer options (Closes #28)
1 parent 247284d commit 2c551bb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ function collectPaths(value, paths) {
1111
return paths;
1212
}
1313

14+
function coerceInt(value, defaultValue) {
15+
var int = parseInt(value);
16+
17+
if (typeof int == 'number') {
18+
return int;
19+
}
20+
else {
21+
return defaultValue;
22+
}
23+
}
24+
1425
var config = {
1526
step_def_dir: './step-definitions',
1627
page_obj_dir: './page-objects',
@@ -38,7 +49,7 @@ program
3849
.option('-j, --junit <path>', 'output path to save junit-report.xml defaults to ' + config.reports_dir)
3950
.option('-t, --tags <tagName>', 'name of tag to run')
4051
.option('-f, --featureFile <path>', 'a specific feature file to run')
41-
.option('-x, --timeOut <n>', 'steps definition timeout in milliseconds. defaults to ' + config.timeout, parseInt, config.timeout)
52+
.option('-x, --timeOut <n>', 'steps definition timeout in milliseconds. defaults to ' + config.timeout, coerceInt, config.timeout)
4253
.option('-n, --noScreenshot [optional]', 'disable auto capturing of screenshots when an error is encountered')
4354
.parse(process.argv);
4455

0 commit comments

Comments
 (0)