1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-03 04:48:52 -05:00

fix(install): deno install -f should overwrite lockfile from previous installation (#16744)

This commit is contained in:
David Sherret 2022-11-21 14:24:51 -05:00 committed by GitHub
parent a300b968b0
commit 4b07c7b159
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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]