Skip to content

Commit 6003e6d

Browse files
authored
chore: revert populate-- logic (#91)
BREAKING CHANGE: populate-- now defaults to false.
1 parent 0552218 commit 6003e6d

3 files changed

Lines changed: 13 additions & 19 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,15 @@ node example.js -x 1 2 -x 3 4
250250
{ _: [], x: [[1, 2], [3, 4]] }
251251
```
252252
253-
### `populate--`
253+
### populate --
254254
255-
* default: `true`.
255+
* default: `false`.
256+
* key: `populate--`
256257
257258
Should unparsed flags be stored in `--` or `_`.
258259
259260
_If disabled:_
261+
260262
```sh
261263
node example.js a -b -- x y
262264
{ _: [ 'a', 'x', 'y' ], b: true }

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function parse (args, opts) {
1818
'boolean-negation': true,
1919
'duplicate-arguments-array': true,
2020
'flatten-duplicate-arrays': true,
21-
'populate--': true
21+
'populate--': false
2222
}, opts.configuration)
2323
var defaults = opts.default || {}
2424
var configObjects = opts.configObjects || []

test/yargs-parser.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,6 @@ describe('yargs-parser', function () {
115115
parse.should.have.property('_').and.deep.equal(['bare', '--not-a-flag', '-', '-h', '-multi', '--', 'eek'])
116116
})
117117

118-
it('should not populate "--" if parsing was not stopped', function () {
119-
var parse = parser([ '-b' ])
120-
parse.should.not.have.property('--')
121-
})
122-
123-
it('should populate "--" if parsing is stopped', function () {
124-
var parse = parser([ '-b', '--', 'foo bar' ])
125-
parse.should.have.property('--')
126-
})
127-
128118
it('should parse numbers appropriately', function () {
129119
var argv = parser([
130120
'-x', '1234',
@@ -2222,25 +2212,27 @@ describe('yargs-parser', function () {
22222212
})
22232213

22242214
describe('populate--', function () {
2225-
it('should populate "_" if "populate-- false', function () {
2215+
it('should populate "_" by default', function () {
22262216
var result = parser([
22272217
'bare',
22282218
'--', '-h', 'eek', '--'
2229-
], {
2230-
configuration: {'populate--': false}
2231-
})
2219+
])
22322220
result.should.have.property('_').and.deep.equal(['bare', '-h', 'eek', '--'])
22332221
result.should.not.have.property('--')
22342222
})
22352223

2236-
it('should populate the "--" array by default', function () {
2224+
it('should populate the "--" if populate-- is "true"', function () {
22372225
var result = parser([
22382226
'--name=meowmers', 'bare', '-cats', 'woo', 'moxy',
22392227
'-h', 'awesome', '--multi=quux',
22402228
'--key', 'value',
22412229
'-b', '--bool', '--no-meep', '--multi=baz',
22422230
'--', '--not-a-flag', '-', '-h', '-multi', '--', 'eek'
2243-
])
2231+
], {
2232+
configuration: {
2233+
'populate--': true
2234+
}
2235+
})
22442236
result.should.have.property('c', true)
22452237
result.should.have.property('a', true)
22462238
result.should.have.property('t', true)

0 commit comments

Comments
 (0)