summaryrefslogtreecommitdiff
path: root/cli/tools/installer.rs
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-09-05 12:51:37 +0100
committerGitHub <noreply@github.com>2024-09-05 13:51:37 +0200
commit5319b85f14d919c8a3f390a8db53c95922f1cf8d (patch)
tree5bc4c51e7034cc4bfcac2da9c2c8899dcdaa15f1 /cli/tools/installer.rs
parent7d95c5c062c7d836bab912e95587bf7fa52326c4 (diff)
feat(uninstall): alias to 'deno remove' if -g flag missing (#25461)
Close https://github.com/denoland/deno/issues/25457
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r--cli/tools/installer.rs38
1 files changed, 19 insertions, 19 deletions
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<Flags>,
+ 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());