mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
fix: ignore local lockfile for deno install and uninstall (#17145)
Closes #17116
This commit is contained in:
parent
ba8156e578
commit
f9be46cd6c
2 changed files with 36 additions and 2 deletions
|
@ -19,6 +19,8 @@ use crate::tools::fmt::format_json;
|
|||
use crate::util;
|
||||
use crate::Flags;
|
||||
|
||||
use super::DenoSubcommand;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LockfileError(String);
|
||||
|
||||
|
@ -96,7 +98,12 @@ impl Lockfile {
|
|||
flags: &Flags,
|
||||
maybe_config_file: Option<&ConfigFile>,
|
||||
) -> Result<Option<Lockfile>, AnyError> {
|
||||
if flags.no_lock {
|
||||
if flags.no_lock
|
||||
|| matches!(
|
||||
flags.subcommand,
|
||||
DenoSubcommand::Install(_) | DenoSubcommand::Uninstall(_)
|
||||
)
|
||||
{
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ mod install {
|
|||
let temp_dir = TempDir::new();
|
||||
let temp_dir_str = temp_dir.path().to_string_lossy().to_string();
|
||||
|
||||
// ensure a lockfile doesn't get created or updated locally
|
||||
temp_dir.write("deno.json", "{}");
|
||||
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(temp_dir.path())
|
||||
.arg("install")
|
||||
|
@ -34,6 +37,9 @@ mod install {
|
|||
.unwrap();
|
||||
assert!(status.success());
|
||||
|
||||
// no lockfile should be created locally
|
||||
assert!(!temp_dir.path().join("deno.lock").exists());
|
||||
|
||||
let mut file_path = temp_dir.path().join(".deno/bin/echo_test");
|
||||
assert!(file_path.exists());
|
||||
|
||||
|
@ -41,7 +47,7 @@ mod install {
|
|||
file_path = file_path.with_extension("cmd");
|
||||
}
|
||||
|
||||
let content = fs::read_to_string(file_path).unwrap();
|
||||
let content = fs::read_to_string(&file_path).unwrap();
|
||||
// ensure there's a trailing newline so the shell script can be
|
||||
// more versatile.
|
||||
assert_eq!(content.chars().last().unwrap(), '\n');
|
||||
|
@ -57,6 +63,27 @@ mod install {
|
|||
r#"run --check 'http://localhost:4545/echo.ts'"#
|
||||
);
|
||||
}
|
||||
|
||||
// now uninstall
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(temp_dir.path())
|
||||
.arg("uninstall")
|
||||
.arg("echo_test")
|
||||
.envs([
|
||||
("HOME", temp_dir_str.as_str()),
|
||||
("USERPROFILE", temp_dir_str.as_str()),
|
||||
("DENO_INSTALL_ROOT", ""),
|
||||
])
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
|
||||
// ensure local lockfile still doesn't exist
|
||||
assert!(!temp_dir.path().join("deno.lock").exists());
|
||||
// ensure uninstall occurred
|
||||
assert!(!file_path.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue