File tree 2 files changed +12
-2
lines changed
Filter options
2 files changed +12
-2
lines changed
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ module.exports = function (args, opts) {
164
164
next = args [ i + 1 ] ;
165
165
if (
166
166
next !== undefined
167
- && ! ( / ^ - / ) . test ( next )
167
+ && ! ( / ^ ( - | - - ) [ ^ - ] / ) . test ( next )
168
168
&& ! flags . bools [ key ]
169
169
&& ! flags . allBools
170
170
&& ( aliases [ key ] ? ! aliasIsBoolean ( key ) : true )
Original file line number Diff line number Diff line change @@ -4,8 +4,9 @@ var parse = require('../');
4
4
var test = require ( 'tape' ) ;
5
5
6
6
test ( '-' , function ( t ) {
7
- t . plan ( 5 ) ;
7
+ t . plan ( 6 ) ;
8
8
t . deepEqual ( parse ( [ '-n' , '-' ] ) , { n : '-' , _ : [ ] } ) ;
9
+ t . deepEqual ( parse ( [ '--nnn' , '-' ] ) , { nnn : '-' , _ : [ ] } ) ;
9
10
t . deepEqual ( parse ( [ '-' ] ) , { _ : [ '-' ] } ) ;
10
11
t . deepEqual ( parse ( [ '-f-' ] ) , { f : '-' , _ : [ ] } ) ;
11
12
t . deepEqual (
@@ -31,3 +32,12 @@ test('move arguments after the -- into their own `--` array', function (t) {
31
32
{ name : 'John' , _ : [ 'before' ] , '--' : [ 'after' ] }
32
33
) ;
33
34
} ) ;
35
+
36
+ test ( '--- option value' , function ( t ) {
37
+ // A multi-dash value is largely an edge case, but check the behaviour is as expected,
38
+ // and in particular the same for short option and long option (as made consistent in Jan 2023).
39
+ t . plan ( 2 ) ;
40
+ t . deepEqual ( parse ( [ '-n' , '---' ] ) , { n : '---' , _ : [ ] } ) ;
41
+ t . deepEqual ( parse ( [ '--nnn' , '---' ] ) , { nnn : '---' , _ : [ ] } ) ;
42
+ } ) ;
43
+
You can’t perform that action at this time.
0 commit comments