yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.42k stars 2.72k forks source link

Incorrect error message if flag passed before first command. #2943

Closed merriam closed 7 years ago

merriam commented 7 years ago

Do you want to request a feature or report a bug? bug

What is the current behavior? I get the incorrect and cryptic error message for passing a command line parameter before the command. I should get an error such as error: flag (-D) passed before first command. Run as yarn add -D ...

There is no need to guess and correct the command, which seems to be a flagellated deceased equine (See #635, #777, #716, #693, #1002, etc.). There is a need to put a correct error message. Currently, the error message includes Run "yarn add add ...." which is clearly incorrect.

If the current behavior is a bug, please provide the steps to reproduce.

$yarn -D add eslint-plugin-prefer-object-spread
yarn install v0.21.3
error `install` has been replaced with `add` to add new dependencies. Run "yarn add add eslint-plugin-prefer-object-spread --dev" instead.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

What is the expected behavior?

$yarn -D add eslint-plugin-prefer-object-spread
yarn install v0.21.3
error yarn option -D passed before a valid yarn command.   Run "yard add -D eslint-plugin-prefer-object-spread" instead.

Please mention your node.js, yarn and operating system version. yarn v0.21.3, node v7.7.1, MacOS Sierra v10.12.3

andimarek commented 7 years ago

It seems to me that a solution for this has already been rejected once: https://github.com/yarnpkg/yarn/pull/716

merriam commented 7 years ago

Yes. The solution of trying to divine the users intention and act on that guess was rejected.

The solution of printing a sensible error message should still be considered.