File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ class ERR_INVALID_ARG_TYPE extends TypeError {
77 }
88}
99
10- class ERR_INVALID_SHORT_OPTION extends TypeError {
11- constructor ( longOption , shortOption ) {
12- super ( `options. ${ longOption } .short must be a single character, got '${ shortOption } '` ) ;
13- this . code = 'ERR_INVALID_SHORT_OPTION ' ;
10+ class ERR_INVALID_ARG_VALUE extends TypeError {
11+ constructor ( arg1 , arg2 , expected ) {
12+ super ( `The property ${ arg1 } ${ expected } . Received '${ arg2 } '` ) ;
13+ this . code = 'ERR_INVALID_ARG_VALUE ' ;
1414 }
1515}
1616
1717module . exports = {
1818 codes : {
1919 ERR_INVALID_ARG_TYPE ,
20- ERR_INVALID_SHORT_OPTION
20+ ERR_INVALID_ARG_VALUE
2121 }
2222} ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ const {
3434
3535const {
3636 codes : {
37- ERR_INVALID_SHORT_OPTION ,
37+ ERR_INVALID_ARG_VALUE ,
3838 } ,
3939} = require ( './errors' ) ;
4040
@@ -117,7 +117,11 @@ const parseArgs = ({
117117 const shortOption = optionConfig . short ;
118118 validateString ( shortOption , `options.${ longOption } .short` ) ;
119119 if ( shortOption . length !== 1 ) {
120- throw new ERR_INVALID_SHORT_OPTION ( longOption , shortOption ) ;
120+ throw new ERR_INVALID_ARG_VALUE (
121+ `options.${ longOption } .short` ,
122+ shortOption ,
123+ 'must be a single character'
124+ ) ;
121125 }
122126 }
123127
Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ test('invalid short option length', (t) => {
412412 const passedOptions = { foo : { short : 'fo' , type : 'boolean' } } ;
413413
414414 t . throws ( function ( ) { parseArgs ( { args : passedArgs , options : passedOptions } ) ; } , {
415- code : 'ERR_INVALID_SHORT_OPTION '
415+ code : 'ERR_INVALID_ARG_VALUE '
416416 } ) ;
417417
418418 t . end ( ) ;
You can’t perform that action at this time.
0 commit comments