Skip to content

Confusing order of CLI flags #4470

@zemlanin

Description

@zemlanin

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

What is the current behavior?
I've got this script in package.json:

    "build": "webpack --config a.config.js --config b.config.js",

In v0.27.5 (and prior) command yarn build --no-progress --prod called webpack --config a.config.js --config b.config.js with production NODE_ENV

Now, after update to [email protected], the same yarn build --no-progress --prod calls webpack --config a.config.js --config b.config.js "--no-progress" "--prod", passing through --no-progress --prod to webpack

I've tried to rearrange arguments in yarn build --no-progress --prod so that it worked as previously, but:

  • yarn run build --no-progress --prod still calls webpack --config a.config.js --config b.config.js "--no-progress" "--prod"
  • yarn run --no-progress --prod build (maybe I needed set yarn flags before script name) results in error Command "--prod" not found.
    • (flags reordering only changes "not found" command name)
  • yarn --no-progress --prod run build results in error No command specified.
  • and only yarn --prod --no-progress run build (alongside with yarn --prod --no-progress build) worked as expected

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

https://gist.github.com/zemlanin/67f3d1db3dc39997bf9aa164a358eb1b

$ git clone https://gist.github.com/67f3d1db3dc39997bf9aa164a358eb1b.git yarn-flags-order

$ cd yarn-flags-order

$ yarn echo --no-progress --prod
  yarn echo v1.0.2
  $ echo $NODE_ENV "--no-progress" "--prod"
  --no-progress --prod
  ✨  Done in 0.13s.

$ yarn --no-progress --prod echo
  yarn echo v1.0.2
  error No command specified.
  info Commands available from binary scripts: 
  info Project commands
     - echo
        echo $NODE_ENV
  ^C
  error No command specified.
  ✨  Done in 2.98s.

$ yarn --prod --no-progress echo
  yarn echo v1.0.2
  $ echo $NODE_ENV
  production
  ✨  Done in 0.12s.

What is the expected behavior?

  • flags before double-dash (--) do not pass to the script
  • order of the flags should not be important (at least in this case)

Please mention your node.js, yarn and operating system version.

$ node -v
v8.5.0
$ yarn -v
1.0.2
# OS X 10.12.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions