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

fix(publish): Run pre and postpack lifecycle scripts on publish #5712

Merged
merged 2 commits into from
Apr 26, 2018

Conversation

rally25rs
Copy link
Contributor

Summary

npm runs the pre and post pack scripts on publish, but yarn was not. Added these scripts.

fixes #5707

Test plan

Added a test that regex's the output to look for scripts being run.
If you look at the test, the regex is kinda weird, but I did it that way to make sure the log statements were in the correct order in the output.

npm runs the pre and post pack scripts on publish, but yarn was not. Added these scripts.

fixes yarnpkg#5707
@@ -44,6 +44,7 @@ async function publish(config: Config, pkg: any, flags: Object, dir: string): Pr
await config.executeLifecycleScript('prepublish');
await config.executeLifecycleScript('prepare');
await config.executeLifecycleScript('prepublishOnly');
await config.executeLifecycleScript('prepack');
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't those lifecycles be part of the pack command rather than publish?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They already are, but they are in pack's run() function which is not called directly by publish. I considered moving them into the commonly called pack() function, but postpack shouldn't be executed until the output stream is written, so it makes refactoring the scripts to be called in a common spot a bit more complicated. I took the easier route here.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, thanks for the explanation 👍

Copy link
Member

Choose a reason for hiding this comment

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

Shall we put that explanation in the code as a comment?

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.

yarn publish does not run prepack/postpack
3 participants