From 5319b85f14d919c8a3f390a8db53c95922f1cf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 5 Sep 2024 12:51:37 +0100 Subject: feat(uninstall): alias to 'deno remove' if -g flag missing (#25461) Close https://github.com/denoland/deno/issues/25457 --- cli/tools/installer.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 987f3c069..065c5aa1c 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -198,14 +198,15 @@ pub async fn infer_name_from_url( Some(stem.to_string()) } -pub fn uninstall(uninstall_flags: UninstallFlags) -> Result<(), AnyError> { - if !uninstall_flags.global { - log::warn!("⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag."); - } - +pub async fn uninstall( + flags: Arc, + uninstall_flags: UninstallFlags, +) -> Result<(), AnyError> { let uninstall_flags = match uninstall_flags.kind { UninstallKind::Global(flags) => flags, - UninstallKind::Local => unreachable!(), + UninstallKind::Local(remove_flags) => { + return super::registry::remove(flags, remove_flags).await; + } }; let cwd = std::env::current_dir().context("Unable to get CWD")?; @@ -332,10 +333,6 @@ pub async fn install_command( ) -> Result<(), AnyError> { match install_flags.kind { InstallKind::Global(global_flags) => { - if !install_flags.global { - log::warn!("⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag."); - } - install_global(flags, global_flags).await } InstallKind::Local(local_flags) => { @@ -1512,8 +1509,8 @@ mod tests { assert!(content.contains(&expected_string)); } - #[test] - fn uninstall_basic() { + #[tokio::test] + async fn uninstall_basic() { let temp_dir = TempDir::new(); let bin_dir = temp_dir.path().join("bin"); std::fs::create_dir(&bin_dir).unwrap(); @@ -1540,13 +1537,16 @@ mod tests { File::create(file_path).unwrap(); } - uninstall(UninstallFlags { - kind: UninstallKind::Global(UninstallFlagsGlobal { - name: "echo_test".to_string(), - root: Some(temp_dir.path().to_string()), - }), - global: false, - }) + uninstall( + Default::default(), + UninstallFlags { + kind: UninstallKind::Global(UninstallFlagsGlobal { + name: "echo_test".to_string(), + root: Some(temp_dir.path().to_string()), + }), + }, + ) + .await .unwrap(); assert!(!file_path.exists()); -- cgit v1.2.3