@@ -30,16 +30,24 @@ process.on('unhandledRejection', (reason, promise) => {
3030 console . error ( 'Unhandled Rejection at:' , promise , 'reason:' , reason ) ;
3131} ) ;
3232
33+ function myParseInt ( value , dummyPrevious ) {
34+ const parsedValue = parseInt ( value , 10 ) ;
35+ if ( isNaN ( parsedValue ) ) {
36+ throw new commander . InvalidArgumentError ( 'Not a number.' ) ;
37+ }
38+ return parsedValue ;
39+ }
40+
3341program
3442 . version ( pck . version )
35- . option ( '-p, --port <number>' , 'Port to listen on' , parseInt , 8100 )
43+ . option ( '-p, --port <number>' , 'Port to listen on' , myParseInt , 8100 )
3644 . option ( '-h, --hostname <string>' , 'Hostname to bind to' , 'localhost' )
3745 . option ( '-c, --config <string>' , 'Path to the configuration file' )
3846 . action ( startServer ) ;
3947
4048// Deprecated start command for backwards compatibility
4149program . command ( 'start' )
42- . option ( '-p, --port <number>' , 'Port to listen on' , parseInt , 8100 )
50+ . option ( '-p, --port <number>' , 'Port to listen on' , myParseInt , 8100 )
4351 . option ( '-h, --hostname <string>' , 'Hostname to bind to' , 'localhost' )
4452 . option ( '-l, --log-level <string>' , 'Log level' , 'info' )
4553 . option ( '-c, --config <string>' , 'Path to the configuration file' )
0 commit comments