@@ -31,7 +31,7 @@ function isNumeric(s) {
31
31
}
32
32
33
33
function parseOptions ( args ) {
34
- var opts = {
34
+ const opts = {
35
35
"doc_folder" : "" ,
36
36
"tests_folder" : "" ,
37
37
"files" : [ ] ,
@@ -42,7 +42,7 @@ function parseOptions(args) {
42
42
"executable_path" : null ,
43
43
"no_sandbox" : false ,
44
44
} ;
45
- var correspondances = {
45
+ const correspondances = {
46
46
"--doc-folder" : "doc_folder" ,
47
47
"--tests-folder" : "tests_folder" ,
48
48
"--debug" : "debug" ,
@@ -52,39 +52,41 @@ function parseOptions(args) {
52
52
"--no-sandbox" : "no_sandbox" ,
53
53
} ;
54
54
55
- for ( var i = 0 ; i < args . length ; ++ i ) {
56
- if ( args [ i ] === "--doc-folder"
57
- || args [ i ] === "--tests-folder"
58
- || args [ i ] === "--file"
59
- || args [ i ] === "--jobs"
60
- || args [ i ] === "--executable-path" ) {
55
+ for ( let i = 0 ; i < args . length ; ++ i ) {
56
+ const arg = args [ i ] ;
57
+ if ( arg === "--doc-folder"
58
+ || arg === "--tests-folder"
59
+ || arg === "--file"
60
+ || arg === "--jobs"
61
+ || arg === "--executable-path" ) {
61
62
i += 1 ;
62
63
if ( i >= args . length ) {
63
- console . log ( "Missing argument after `" + args [ i - 1 ] + "` option." ) ;
64
+ console . log ( "Missing argument after `" + arg + "` option." ) ;
64
65
return null ;
65
66
}
66
- if ( args [ i - 1 ] === "--jobs" ) {
67
- if ( ! isNumeric ( args [ i ] ) ) {
67
+ const arg_value = args [ i ] ;
68
+ if ( arg === "--jobs" ) {
69
+ if ( ! isNumeric ( arg_value ) ) {
68
70
console . log (
69
- "`--jobs` option expects a positive number, found `" + args [ i ] + "`" ) ;
71
+ "`--jobs` option expects a positive number, found `" + arg_value + "`" ) ;
70
72
return null ;
71
73
}
72
- opts [ "jobs" ] = parseInt ( args [ i ] ) ;
73
- } else if ( args [ i - 1 ] !== "--file" ) {
74
- opts [ correspondances [ args [ i - 1 ] ] ] = args [ i ] ;
74
+ opts [ "jobs" ] = parseInt ( arg_value ) ;
75
+ } else if ( arg !== "--file" ) {
76
+ opts [ correspondances [ arg ] ] = arg_value ;
75
77
} else {
76
- opts [ "files" ] . push ( args [ i ] ) ;
78
+ opts [ "files" ] . push ( arg_value ) ;
77
79
}
78
- } else if ( args [ i ] === "--help" ) {
80
+ } else if ( arg === "--help" ) {
79
81
showHelp ( ) ;
80
82
process . exit ( 0 ) ;
81
- } else if ( args [ i ] === "--no-sandbox" ) {
83
+ } else if ( arg === "--no-sandbox" ) {
82
84
console . log ( "`--no-sandbox` is being used. Be very careful!" ) ;
83
- opts [ correspondances [ args [ i ] ] ] = true ;
84
- } else if ( correspondances [ args [ i ] ] ) {
85
- opts [ correspondances [ args [ i ] ] ] = true ;
85
+ opts [ correspondances [ arg ] ] = true ;
86
+ } else if ( correspondances [ arg ] ) {
87
+ opts [ correspondances [ arg ] ] = true ;
86
88
} else {
87
- console . log ( "Unknown option `" + args [ i ] + "`." ) ;
89
+ console . log ( "Unknown option `" + arg + "`." ) ;
88
90
console . log ( "Use `--help` to see the list of options" ) ;
89
91
return null ;
90
92
}
@@ -186,7 +188,7 @@ function createEmptyResults() {
186
188
}
187
189
188
190
async function main ( argv ) {
189
- let opts = parseOptions ( argv . slice ( 2 ) ) ;
191
+ const opts = parseOptions ( argv . slice ( 2 ) ) ;
190
192
if ( opts === null ) {
191
193
process . exit ( 1 ) ;
192
194
}
0 commit comments