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

Run the prepare script of git dependencies even if NODE_ENV=production #7398

Merged
merged 4 commits into from Jul 24, 2019

Conversation

jfirebaugh
Copy link
Contributor

@jfirebaugh jfirebaugh commented Jul 13, 2019

Summary

When installing a git dependency with the NODE_ENV environment variable set to production, yarn did not run the prepare lifecycle script, because config.production would default to true, and then wrapLifecycle would skip prepare:

if (!config.production) {
if (!config.disablePrepublish) {
await config.executeLifecycleScript('prepublish');
}
await config.executeLifecycleScript('prepare');
}

This is contrary to npm's behavior and the intent of GitFetcher#fetchFromInstallAndPack, which is to install the dependency with its devDependencies and run all the relevant lifecycle scripts (excluding prepublish), regardless of the configuration or environment settings of the parent install command.

Test plan

Added an automated test.

cc @Volune, who added the original feature in #3553. Thanks for the test case which I cribbed from!

When installing a git dependency with the `NODE_ENV` environment variable set to `production`, yarn did not run the `prepare` lifecycle script, because `config.production` would default to true, and then `wrapLifecycle` would skip `prepare`:

https://github.com/yarnpkg/yarn/blob/b6569538de69e0ccd201f0a33f1f5b52f2656f5b/src/cli/commands/install.js#L1202-L1207

This is contrary to npm's behavior and the intent of `GitFetcher#fetchFromInstallAndPack`, which is to install the dependency with its devDependencies and run all the relevant lifecycle scripts (excluding `prepublish`), regardless of the configuration or environment settings of the parent install command.
@arcanis
Copy link
Member

arcanis commented Jul 15, 2019

Looks good to me! Can you update the CHANGELOG file?

@arcanis arcanis merged commit ee29a5f into yarnpkg:master Jul 24, 2019
@arcanis
Copy link
Member

arcanis commented Jul 24, 2019

Thanks!

@buildsize
Copy link

buildsize bot commented Jul 24, 2019

File name Previous Size New Size Change
yarn-[version].noarch.rpm 1.18 MB 1.18 MB -48 bytes (0%)
yarn-[version].js 4.85 MB 4.85 MB 50 bytes (0%)
yarn-legacy-[version].js 5.05 MB 5.05 MB 80 bytes (0%)
yarn-v[version].tar.gz 1.19 MB 1.18 MB -1.95 KB (0%)
yarn_[version]all.deb 868.7 KB 868.41 KB -290 bytes (0%)

VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
yarnpkg#7398)

* Run the prepare script of git dependencies even if NODE_ENV=production

When installing a git dependency with the `NODE_ENV` environment variable set to `production`, yarn did not run the `prepare` lifecycle script, because `config.production` would default to true, and then `wrapLifecycle` would skip `prepare`:

https://github.com/yarnpkg/yarn/blob/b6569538de69e0ccd201f0a33f1f5b52f2656f5b/src/cli/commands/install.js#L1202-L1207

This is contrary to npm's behavior and the intent of `GitFetcher#fetchFromInstallAndPack`, which is to install the dependency with its devDependencies and run all the relevant lifecycle scripts (excluding `prepublish`), regardless of the configuration or environment settings of the parent install command.

* Update CHANGELOG.md

* Update CHANGELOG.md
VincentBailly pushed a commit to VincentBailly/yarn that referenced this pull request Jun 10, 2020
yarnpkg#7398)

* Run the prepare script of git dependencies even if NODE_ENV=production

When installing a git dependency with the `NODE_ENV` environment variable set to `production`, yarn did not run the `prepare` lifecycle script, because `config.production` would default to true, and then `wrapLifecycle` would skip `prepare`:

https://github.com/yarnpkg/yarn/blob/b6569538de69e0ccd201f0a33f1f5b52f2656f5b/src/cli/commands/install.js#L1202-L1207

This is contrary to npm's behavior and the intent of `GitFetcher#fetchFromInstallAndPack`, which is to install the dependency with its devDependencies and run all the relevant lifecycle scripts (excluding `prepublish`), regardless of the configuration or environment settings of the parent install command.

* Update CHANGELOG.md

* Update CHANGELOG.md
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.

None yet

2 participants