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 {
7
7
}
8
8
}
9
9
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 ' ;
14
14
}
15
15
}
16
16
17
17
module . exports = {
18
18
codes : {
19
19
ERR_INVALID_ARG_TYPE ,
20
- ERR_INVALID_SHORT_OPTION
20
+ ERR_INVALID_ARG_VALUE
21
21
}
22
22
} ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ const {
34
34
35
35
const {
36
36
codes : {
37
- ERR_INVALID_SHORT_OPTION ,
37
+ ERR_INVALID_ARG_VALUE ,
38
38
} ,
39
39
} = require ( './errors' ) ;
40
40
@@ -117,7 +117,11 @@ const parseArgs = ({
117
117
const shortOption = optionConfig . short ;
118
118
validateString ( shortOption , `options.${ longOption } .short` ) ;
119
119
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
+ ) ;
121
125
}
122
126
}
123
127
Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ test('invalid short option length', (t) => {
412
412
const passedOptions = { foo : { short : 'fo' , type : 'boolean' } } ;
413
413
414
414
t . throws ( function ( ) { parseArgs ( { args : passedArgs , options : passedOptions } ) ; } , {
415
- code : 'ERR_INVALID_SHORT_OPTION '
415
+ code : 'ERR_INVALID_ARG_VALUE '
416
416
} ) ;
417
417
418
418
t . end ( ) ;
You can’t perform that action at this time.
0 commit comments