fix(cli): cover every npm install lifecycle hook

npm runs prepublish, preprepare and postprepare on install too, so a project
using one of those would have had its install layer split and the hook would
run against a source tree that is not there yet.
This commit is contained in:
Elior Nataf Lackritz
2026-08-12 16:03:24 -04:00
parent 77fbf25d41
commit 750f31482e
2 changed files with 20 additions and 3 deletions
+10 -2
View File
@@ -1162,8 +1162,16 @@ def _build_runtime_env_vars(config: Config) -> list[str]:
return env_vars
# These run as part of the install step, before the source would be copied.
_NODE_INSTALL_HOOKS = ("preinstall", "install", "postinstall", "prepare")
# npm runs all of these as part of an install, before the source would be copied.
_NODE_INSTALL_HOOKS = (
"preinstall",
"install",
"postinstall",
"prepublish",
"preprepare",
"prepare",
"postprepare",
)
def _splittable_node_manifests(
+10 -1
View File
@@ -3531,7 +3531,16 @@ class TestNodeDependencyLayerOrdering:
)
@pytest.mark.parametrize(
"hook", ["preinstall", "install", "postinstall", "prepare"]
"hook",
[
"preinstall",
"install",
"postinstall",
"prepublish",
"preprepare",
"prepare",
"postprepare",
],
)
def test_install_hook_keeps_source_first(
self, tmp_path: pathlib.Path, hook: str