Skip to main content

clear_unless_valid

Function clear_unless_valid 

Source
pub fn clear_unless_valid(dir: &Path, cli_command: &str) -> Result<()>
Expand description

Under the install lock, before (re)installing into dir: unless it holds a valid install, remove it entirely — leftovers of a failed or interrupted install, and a stale completion marker whose shim is gone. Removing the marker is the point: a repair must not run with the old marker visible, or readers would accept the half-repaired install as soon as npm recreates the shim, and a failed repair would leave marker + shim accepted indefinitely (Codex P2 on #3927, second pass). No-op for a missing or valid dir.