@@ -119,7 +119,8 @@ function _assignOption(
119119 ignored : string [ ] ,
120120 errors : string [ ] ,
121121) {
122- let key = arg . substr ( 2 ) ;
122+ const from = arg . startsWith ( '--' ) ? 2 : 1 ;
123+ let key = arg . substr ( from ) ;
123124 let option : Option | null = null ;
124125 let value = '' ;
125126 const i = arg . indexOf ( '=' ) ;
@@ -172,8 +173,9 @@ function _assignOption(
172173 value = arg . substring ( i + 1 ) ;
173174 }
174175 }
176+
175177 if ( option === null ) {
176- if ( args [ 0 ] && ! args [ 0 ] . startsWith ( '-- ' ) ) {
178+ if ( args [ 0 ] && ! args [ 0 ] . startsWith ( '-' ) ) {
177179 leftovers . push ( arg , args [ 0 ] ) ;
178180 args . shift ( ) ;
179181 } else {
@@ -285,14 +287,14 @@ export function parseArguments(args: string[], options: Option[] | null): Argume
285287 const flag = arg [ i ] ;
286288 // If the next character is an '=', treat it as a long flag.
287289 if ( arg [ i + 1 ] == '=' ) {
288- const f = '-- ' + flag + arg . slice ( i + 1 ) ;
290+ const f = '-' + flag + arg . slice ( i + 1 ) ;
289291 _assignOption ( f , args , options , parsedOptions , positionals , leftovers , ignored , errors ) ;
290292 break ;
291293 }
292294 // Treat the last flag as `--a` (as if full flag but just one letter). We do this in
293295 // the loop because it saves us a check to see if the arg is just `-`.
294296 if ( i == arg . length - 1 ) {
295- const arg = '-- ' + flag ;
297+ const arg = '-' + flag ;
296298 _assignOption ( arg , args , options , parsedOptions , positionals , leftovers , ignored , errors ) ;
297299 } else {
298300 const maybeOption = _getOptionFromName ( flag , options ) ;
0 commit comments