This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
publish: simplify lifecycle invocation
Previously (in 0ab0c11) support was added for running the publish and postpublish lifecycle scripts. Some work was done to ensure that this was run in the correct path both when publishing from the package's working directory, as well as when publishing from a package tarball file or URL. The latter case is interesting, because it would only ever work for lifecycle scripts that didn't rely on bins exported by (dev)dependencies, due to being run directly from the cached package.json. In the process, there was a lot of inline use of ternary operators that made it very hard to understand what was going on. There are two ways to fix this: 1. An expensive way, which is to explode the package once it's been cached, install it, and then run the lifecycle scripts from that directory. 2. A cheap way, which is to assume that whatever scripts needed to be run were already run when packing the tarball or remote package, and just don't run the lifecycle scripts at all unless you're publishing from the working directory. This patch opts for approach #2. Publishing directly from tarballs is an option for power users, and having lifecycle events fire in that case is a conflation of the build and upload stages of publish that cuts against what (I believe) most users are trying to do, which is to build an artifact, certify it, and then only publish it if certification succeeds. However, this is technically a breaking change, and as such should either ship before `npm@4` becomes latest, or be held for `npm@5`. (I'd prefer the former, but leave that for the team to decide.) Credit: @othiym23 Fixes: #14493 Reviewed-By: @iarna PR-URL: #14502
- Loading branch information
Showing
3 changed files
with
120 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters