diff options
-rw-r--r-- | cli/args/lockfile.rs | 9 | ||||
-rw-r--r-- | cli/tests/install_tests.rs | 29 |
2 files changed, 36 insertions, 2 deletions
diff --git a/cli/args/lockfile.rs b/cli/args/lockfile.rs index 012d9782e..1b5eddf3a 100644 --- a/cli/args/lockfile.rs +++ b/cli/args/lockfile.rs @@ -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); } diff --git a/cli/tests/install_tests.rs b/cli/tests/install_tests.rs index 4016b6373..3d799ce53 100644 --- a/cli/tests/install_tests.rs +++ b/cli/tests/install_tests.rs @@ -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] |