Skip to content

Commit

Permalink
Merge pull request #525 from JustATrick/allow-literal-passthrough
Browse files Browse the repository at this point in the history
Allow literal '--' to be passed-through as an argument
  • Loading branch information
zhiyelee committed Jul 1, 2016
2 parents 7a281b9 + d49573a commit c86ba2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions index.js
Expand Up @@ -668,13 +668,13 @@ Command.prototype.parseOptions = function(argv) {
arg = argv[i];

// literal args after --
if ('--' == arg) {
literal = true;
if (literal) {
args.push(arg);
continue;
}

if (literal) {
args.push(arg);
if ('--' == arg) {
literal = true;
continue;
}

Expand Down
6 changes: 5 additions & 1 deletion test/test.literal.args.js
Expand Up @@ -13,4 +13,8 @@ program
program.parse(['node', 'test', '--foo', '--', '--bar', 'baz']);
program.foo.should.be.true;
should.equal(undefined, program.bar);
program.args.should.eql(['--bar', 'baz']);
program.args.should.eql(['--bar', 'baz']);

// subsequent literals are passed-through as args
program.parse(['node', 'test', '--', 'cmd', '--', '--arg']);
program.args.should.eql(['cmd', '--', '--arg']);

0 comments on commit c86ba2a

Please sign in to comment.