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

npm_config_argv is not set properly in yarn scripts #2226

Closed
dotcs opened this issue Dec 12, 2016 · 4 comments
Closed

npm_config_argv is not set properly in yarn scripts #2226

dotcs opened this issue Dec 12, 2016 · 4 comments

Comments

@dotcs
Copy link

dotcs commented Dec 12, 2016

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

Not clear. To be compatible with npm I guess it's a bug.

What is the current behavior?
Environment variables are not set correctly.

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

// File: env-test.js
console.log(process.env);

and

// File: package.json
{
  "scripts": {
    "env-test": "node ./test.js"
  }
}

What is the expected behavior?

npm_config_argv should be set in process.env, as well as thenpm_config_demo_arg in this case.

$ npm run env-test --demo-arg="abc" | grep 'abc'`
# output:
# npm_config_argv: '{"remain":[],"cooked":["run","env","--demo-arg","abc"],"original":["run","env","--demo-arg=abc"]}',
# npm_config_demo_arg: 'abc',

$ npm run env-test --demo-arg="abc" | grep 'abc'`
# output is empty

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

$ node --version
# output: v7.2.0
$ yarn --version
# output: 0.18.0
$ uname -a
# output: Darwin name.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep  1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64
# (it's Mac OS X El Capitan 10.11.6 (15G1108))
@dotcs
Copy link
Author

dotcs commented Dec 12, 2016

Found this issue which seems linked with the env variables: #684

@ghost
Copy link

ghost commented Sep 15, 2017

It's an issue that I've encountered & been bitten by.

Say you type
npm run foobar then npm_config_argv will show "run" and "foobar" in the both the cookked & original arguments arrays.

However if you type
yarn foobar then npm_config_argv will show only "foobar" in the both the cookked & original arguments arrays, that is, leaving out "run".

So that's a genuine compatibility issue that actually arisen for me.

BYK added a commit that referenced this issue Sep 15, 2017
**Summary**

Fixes #2226. Better emulates `npm_config_argv` by passing
`process.argv.slice(2)` as the `original` portion and both the
command name and the script name in `cooked` portion.

**Test case**

Added integration tests.
@BYK
Copy link
Member

BYK commented Sep 15, 2017

@indiescripter submitted #4479. Hope it helps you a bit?

@ghost
Copy link

ghost commented Sep 15, 2017

@BYK Thanks I'll check your #4479 out.

@BYK BYK closed this as completed in #4479 Sep 18, 2017
BYK added a commit that referenced this issue Sep 18, 2017
**Summary**

Fixes #2226. Better emulates `npm_config_argv` by passing
`process.argv.slice(2)` as the `original` portion and both the
command name and the script name in `cooked` portion.

**Test case**

Added integration tests.
joaolucasl pushed a commit to joaolucasl/yarn that referenced this issue Oct 27, 2017
**Summary**

Fixes yarnpkg#2226. Better emulates `npm_config_argv` by passing
`process.argv.slice(2)` as the `original` portion and both the
command name and the script name in `cooked` portion.

**Test case**

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

No branches or pull requests

3 participants