Skip to content

Commit 0f3766c

Browse files
committed
comment + only if has scripts
1 parent b19ea7d commit 0f3766c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cli/npm/managed/resolvers/common/lifecycle_scripts.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'a> LifecycleScripts<'a> {
6262
}
6363
}
6464

65-
fn has_lifecycle_scripts(
65+
pub fn has_lifecycle_scripts(
6666
package: &NpmResolutionPackage,
6767
package_path: &Path,
6868
) -> bool {
@@ -277,6 +277,10 @@ impl<'a> LifecycleScripts<'a> {
277277
self.strategy.did_run_scripts(package)?;
278278
}
279279

280+
// re-set up bin entries for the packages which we've run scripts for.
281+
// lifecycle scripts can create files that are linked to by bin entries,
282+
// and the only reliable way to handle this is to re-link bin entries
283+
// (this is what PNPM does as well)
280284
bin_entries.finish_only(
281285
snapshot,
282286
&root_node_modules_dir_path.join(".bin"),

cli/npm/managed/resolvers/local.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,13 @@ async fn sync_resolution_with_fs(
664664
|setup_outcome| {
665665
match setup_outcome {
666666
bin_entries::EntrySetupOutcome::MissingEntrypoint {
667-
package, ..
668-
} if lifecycle_scripts.can_run_scripts(&package.id.nv)
667+
package,
668+
package_path,
669+
..
670+
} if super::common::lifecycle_scripts::has_lifecycle_scripts(
671+
package,
672+
package_path,
673+
) && lifecycle_scripts.can_run_scripts(&package.id.nv)
669674
&& !lifecycle_scripts.has_run_scripts(package) =>
670675
{
671676
// ignore, it might get fixed when the lifecycle scripts run.

0 commit comments

Comments
 (0)