Skip to content

Commit a25c04f

Browse files
shubhekshakumar303
authored andcommitted
fix: show an error if an argument is passed to the lint command (#474)
1 parent 45d9c0d commit a25c04f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/program.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class Program {
3838
return;
3939
}
4040
return yargs
41+
.demand(0, 0, 'This command does not take any arguments')
4142
.strict()
4243
.exitProcess(this.shouldExitProgram)
4344
// Calling env() will be unnecessary after

tests/test.program.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ describe('program.Program', () => {
6767
});
6868
});
6969

70+
it('throws an error if sub-command is given an argument', () => {
71+
const program = new Program(['thing', 'nope'])
72+
.command('thing', '', () => {});
73+
return run(program)
74+
.then(makeSureItFails())
75+
.catch((error) => {
76+
assert.match(error.message, /This command does not take any arguments/);
77+
});
78+
});
79+
7080
it('handles errors that have codes', () => {
7181

7282
class ErrorWithCode extends Error {

0 commit comments

Comments
 (0)