summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-11-21 14:24:51 -0500
committerGitHub <noreply@github.com>2022-11-21 14:24:51 -0500
commit4b07c7b159e9fbf956ef1adf9c952ee4347bc5cb (patch)
tree7c08123f96cded20361da589a513df0ae506c54d /cli/tools
parenta300b968b0720434e84ec9d11752e9323513c7c2 (diff)
fix(install): `deno install -f` should overwrite lockfile from previous installation (#16744)
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/installer.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs
index 8a0504ccc..b964619d9 100644
--- a/cli/tools/installer.rs
+++ b/cli/tools/installer.rs
@@ -415,6 +415,10 @@ fn resolve_shim_data(
fs::read_to_string(lock_path)
.with_context(|| format!("error reading {}", lock_path.display()))?,
));
+ } else {
+ // Provide an empty lockfile so that this overwrites any existing lockfile
+ // from a previous installation. This will get populated on first run.
+ extra_files.push((copy_path, "{}".to_string()));
}
}
@@ -758,16 +762,18 @@ mod tests {
)
.unwrap();
- let lock_path = temp_dir
- .join("bin")
- .join("cowsay.lock.json")
- .display()
- .to_string();
+ let lock_path = temp_dir.join("bin").join("cowsay.lock.json");
assert_eq!(
shim_data.args,
- vec!["run", "--allow-all", "--lock", &lock_path, "npm:cowsay"]
+ vec![
+ "run",
+ "--allow-all",
+ "--lock",
+ &lock_path.to_string_lossy(),
+ "npm:cowsay"
+ ]
);
- assert_eq!(shim_data.extra_files, vec![]);
+ assert_eq!(shim_data.extra_files, vec![(lock_path, "{}".to_string())]);
}
#[test]