Skip to content

Adds npm_package_name#2426

Merged
arcanis merged 6 commits intomasterfrom
mael/pkg-name-env
Feb 1, 2021
Merged

Adds npm_package_name#2426
arcanis merged 6 commits intomasterfrom
mael/pkg-name-env

Conversation

@arcanis
Copy link
Copy Markdown
Member

@arcanis arcanis commented Feb 1, 2021

What's the problem this PR addresses?

The $npm_package_name and $npm_package_version variables weren't exposed in order to prevent the explosion of variables we would need to put in the environment, and avoid ambiguities when a package wouldn't list them and would accidentally "inherit" those from other scripts.

After more consideration, I think it's reasonable to add those two since every package will have them, so there's no ambiguity issue.

Fixes #1659

How did you fix it?

Added the relevant environment variables, plus documentation, plus test.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Copy link
Copy Markdown
Member

@merceyz merceyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think yarn exec might benefit from this as well

env: await scriptUtils.makeScriptEnv({project, binFolder}),

@arcanis arcanis merged commit 10ff0a9 into master Feb 1, 2021
@arcanis arcanis deleted the mael/pkg-name-env branch February 1, 2021 16:48
@AleksandrChernyavenko
Copy link
Copy Markdown

Does anybody know when new release of yarn with this changes is going to be released ?

@philippfo9
Copy link
Copy Markdown

When will this be included into the stable release of yarn? Looking forward to it

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

Successfully merging this pull request may close these issues.

[Feature] Add support for package.json script variables

4 participants