nest-cli icon indicating copy to clipboard operation
nest-cli copied to clipboard

CLI commands silently ignore extra command line arguments

Open Pipeliner opened this issue 3 years ago • 2 comments
trafficstars

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

Running nest g resource aa bb cc dd ee creates aa resource in bb folder, silently ignoring trailing arguments.

Minimum reproduction code

https://gist.github.com/Pipeliner/bdbdb1a0813ce3fe14ae0c5a35c158ed

Steps to reproduce

No response

Expected behavior

An error message and non-zero return code.

Package version

8.2.0

NestJS version

8.2.6

Node.js version

No response

In which operating systems have you tested?

  • [ ] macOS
  • [ ] Windows
  • [X] Linux

Other

No response

Pipeliner avatar Feb 09 '22 15:02 Pipeliner

Would you like to create a PR to address this issue?

kamilmysliwiec avatar Feb 10 '22 07:02 kamilmysliwiec

The command is defined at https://github.com/nestjs/nest-cli/blob/master/commands/generate.command.ts#L11 The trailing arguments just go to program.args and so far I see no commander-native way to ensure there are none.

Also the same issue seems to affect at least some other commands, e.g.

$  nest new a b c         
⚡  We will scaffold your app in a few seconds..

CREATE a/.eslintrc.js (631 bytes)
CREATE a/.prettierrc (51 bytes)
CREATE a/README.md (3339 bytes)
CREATE a/nest-cli.json (64 bytes)
...

@kamilmysliwiec what kind of tests would this PR require?

Pipeliner avatar Feb 10 '22 10:02 Pipeliner