Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-v argument to output version is detected anywhere in command, preventing calling any command with a -v argument #266

Open
dbstraight opened this issue Apr 7, 2021 · 2 comments

Comments

@dbstraight
Copy link

Node 12.16.3
env-cmd 10.1.0

npx env-cmd node -v

Output: 10.1.0
Expected output: 12.16.3

If I comment out this line in my node_modules, then it works as expected:

https://github.com/toddbluhm/env-cmd/blob/master/dist/parse-args.js#L77

I don't know enough about commander to propose a fix.

@daveham
Copy link

daveham commented Jun 8, 2021

I ran into this, too and found a solution. env-cmd uses the package commander for its CLI functionality, including support for version, usage and options. That package supports grouping multiple single-letter options into one option parameter. For example, it is interpreting -abcv to be the same as -a -b -c -v. The option -v corresponds to printing the version. The implementation of version just happens to short-circuit any other processing, so if any of the options it sees includes a v, you will get the version number printed out and no other functionality.

The solution is to include -- (documented here) at the right place to tell env-cmd (and commander under the hood) to stop processing further options. Here is a simplified example from my package.json where I was only getting the version number displayed because the v in -derivedDataPath was triggering commander's version handler:

"e2e:build:ios:bad": "env-cmd -x echo -derivedDataPath \\$IOS_DERIVED_PATH",

And here it works correctly by adding in -- to separate options intended for env-cmd from options intended for the tool I am controlling:

"e2e:build:ios:good": "env-cmd -x -- echo -derivedDataPath \\$IOS_DERIVED_PATH",

@itsmebasti
Copy link

This is still a thing. I wasn't able to assign a docker volume using -v, workaround is to use --volume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants