Skip to content

Commit 21e2702

Browse files
committedDec 12, 2021
Allow args after and between options
1 parent 4152aef commit 21e2702

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed
 

‎CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## next
2+
3+
- Allowed args after and between options
4+
15
## 3.0.0-beta.1
26

37
- Restored wrongly removed `Command#extend()`

‎lib/parse-argv.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ module.exports = function parseArgv(command, argv, context, suggestMode) {
131131
};
132132
break;
133133
} else {
134-
if (rawOptions.length !== 0 ||
135-
context.args.length >= command.params.maxCount) {
134+
if (context.args.length >= command.params.maxCount) {
136135
throw new CliError(`Unknown command: ${token}`);
137136
}
138137

‎test/command-args-and-options.js

+15
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ describe('command run', function() {
8383
});
8484
});
8585

86+
it('args & options before', function() {
87+
const actual = command.run(['--foo', '--bar', '123', 'qux']);
88+
89+
assert.deepStrictEqual(actual, {
90+
commandPath: ['test'],
91+
options: {
92+
__proto__: null,
93+
foo: true,
94+
bar: 123
95+
},
96+
args: ['qux'],
97+
literalArgs: null
98+
});
99+
});
100+
86101
it('args & literal args', function() {
87102
const actual = command.run(['qux', '--', '--one', '--two', '123']);
88103

0 commit comments

Comments
 (0)
Please sign in to comment.