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

order of scripts on yarn publish #3992

Open
andreineculau opened this issue Jul 22, 2017 · 5 comments
Open

order of scripts on yarn publish #3992

andreineculau opened this issue Jul 22, 2017 · 5 comments

Comments

@andreineculau
Copy link

Do you want to request a feature or report a bug?
It depends but if strict compatibility with npm is a goal of yarn, this is a bug.

What is the current behavior?
npm publish invokes prepare and prepublishOnly.
yarn publish invokes prepublishOnly and prepare.

If the current behavior is a bug, please provide the steps to reproduce.
See https://github.com/andreineculau/package-json-scripts

What is the expected behavior?
yarn publish invokes prepare and prepublishOnly.

Please mention your node.js, yarn and operating system version.
npm/5.3.0 yarn/0.28.4

@wearhere
Copy link

I think it also makes more sense for prepare to run before prepublishOnly, the assumption being that publishing will make use of any build artifacts generated by prepare.

@BYK
Copy link
Member

BYK commented Aug 29, 2017

Thanks for the report. This looks straightforward to fix, so may be you'd like to try sending a PR? Pinky promise that we'll do our best to support you if you get stuck 😉

@andreineculau
Copy link
Author

I've just had a baby, so pinky promise that my time for quality PRs got slashed /shrug

@Macil
Copy link

Macil commented Oct 10, 2017

This is fixed in yarn v1.2.0 by #4553:

[chris /tmp/yarn-publish-test]$ yarn publish
yarn publish v1.2.0
[1/4] Bumping version...
info Current version: 1.1.0
question New version: 
[2/4] Logging in...
[3/4] Publishing...
$ ( echo prepare && date ) | tee prepare.txt
prepare
Tue Oct 10 10:53:12 PDT 2017
$ ( echo prepublishOnly && date ) | tee prepublishOnly.txt
prepublishOnly
Tue Oct 10 10:53:12 PDT 2017
success Published.
[4/4] Revoking token...
info Not revoking login token, specified via config file.
✨  Done in 12.40s.

@mojavelinux
Copy link

mojavelinux commented Jan 15, 2018

The other problem is that I'm getting different behavior between yarn and npm publish. When I use npm, the package.json is read after my prepublishOnly script. However, in yarn, it is not reread. This makes it impossible for me to affect the contents of package.json when packaging. My use case is to generate a README for the registry.

Here's the offending line:

// TODO this might modify package.json, do we need to reload it?

Shall I file a separate issue to force the package.json to be reloaded?

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

5 participants