-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
docs: postinstall runs for any change #3428
Conversation
@@ -15,7 +15,7 @@ Packages can define in the `scripts` field of their manifest various actions tha | |||
|
|||
- **prepublish** is called before `yarn npm publish` and similar commands (even before the package has been packed). This is the place where you'll want to check that the project is in an ok state. Because it's only called on prepublish, **the prepublish hook shouldn't have side effects.** In particular don't transpile the package sources in prepublish, as people consuming directly your repository (such as through the [`git:` protocol](/features/protocols#git)) wouldn't be able to use your project. | |||
|
|||
- **postinstall** is called after a package got successfully installed on the disk. It is guaranteed to be called in topological order (in other words, your dependencies' postinstalls will always run before yours). For backwards compatibility, **preinstall** and **install** are called as part of **postinstall**. | |||
- **postinstall** is called whenever the dependency tree of your workspace changes -- e.g. when any package is added, removed or changed. It is guaranteed to be called in topological order (in other words, your dependencies' postinstalls will always run before yours). For backwards compatibility, **preinstall** and **install** are called as part of **postinstall**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not limited to workspaces, if the dependency tree of a Package
changes its postinstall
will be run anew
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@merceyz: How about:
is called whenever a dependency tree within the project changes -- e.g. when any package is added, removed or changed.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just:
is called whenever a dependency changes -- e.g. when any package is added, removed or changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Skimming https://yarnpkg.com/advanced/architecture for helpful language, but nothing is jumping out yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Skimming https://yarnpkg.com/advanced/architecture for helpful language, but nothing is jumping out yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is called after dependency tree changes are written to the disk -- e.g. after a package is added, removed or changed.
Based on https://yarnpkg.com/cli/install#details & https://yarnpkg.com/features/workspaces
I've slightly updated this text to make it clearer that this only affects individual subtrees (ie if you depend on |
As per yarnpkg/yarn#8498 (comment)
I also tested locally (
"packageManager": "yarn@3.0.2"
) and verified thatpostinstall
runs in all of the following cases:yarn
yarn
yarn
yarn
Also pondering adding a note about a potential "gotcha" someone may encounter when attempting to debug
postinstall
: output fromecho
is not shown. When running the script below:... Running via
yarn postinstall
will echo "postinstall script ran" (and create a file), but when run as a side effect (e.g.yarn add foo
), a file will be created but "postinstall script ran" is not shown (echo output).