@@ -31,7 +31,7 @@ function isNumeric(s) {
3131}
3232
3333function parseOptions ( args ) {
34- var opts = {
34+ const opts = {
3535 "doc_folder" : "" ,
3636 "tests_folder" : "" ,
3737 "files" : [ ] ,
@@ -42,7 +42,7 @@ function parseOptions(args) {
4242 "executable_path" : null ,
4343 "no_sandbox" : false ,
4444 } ;
45- var correspondances = {
45+ const correspondances = {
4646 "--doc-folder" : "doc_folder" ,
4747 "--tests-folder" : "tests_folder" ,
4848 "--debug" : "debug" ,
@@ -52,39 +52,41 @@ function parseOptions(args) {
5252 "--no-sandbox" : "no_sandbox" ,
5353 } ;
5454
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" ) {
6162 i += 1 ;
6263 if ( i >= args . length ) {
63- console . log ( "Missing argument after `" + args [ i - 1 ] + "` option." ) ;
64+ console . log ( "Missing argument after `" + arg + "` option." ) ;
6465 return null ;
6566 }
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 ) ) {
6870 console . log (
69- "`--jobs` option expects a positive number, found `" + args [ i ] + "`" ) ;
71+ "`--jobs` option expects a positive number, found `" + arg_value + "`" ) ;
7072 return null ;
7173 }
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 ;
7577 } else {
76- opts [ "files" ] . push ( args [ i ] ) ;
78+ opts [ "files" ] . push ( arg_value ) ;
7779 }
78- } else if ( args [ i ] === "--help" ) {
80+ } else if ( arg === "--help" ) {
7981 showHelp ( ) ;
8082 process . exit ( 0 ) ;
81- } else if ( args [ i ] === "--no-sandbox" ) {
83+ } else if ( arg === "--no-sandbox" ) {
8284 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 ;
8688 } else {
87- console . log ( "Unknown option `" + args [ i ] + "`." ) ;
89+ console . log ( "Unknown option `" + arg + "`." ) ;
8890 console . log ( "Use `--help` to see the list of options" ) ;
8991 return null ;
9092 }
@@ -186,7 +188,7 @@ function createEmptyResults() {
186188}
187189
188190async function main ( argv ) {
189- let opts = parseOptions ( argv . slice ( 2 ) ) ;
191+ const opts = parseOptions ( argv . slice ( 2 ) ) ;
190192 if ( opts === null ) {
191193 process . exit ( 1 ) ;
192194 }
0 commit comments