summaryrefslogtreecommitdiff
path: root/cli/tools/installer.rs
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-03-27 22:45:57 +0000
committerGitHub <noreply@github.com>2024-03-27 23:45:57 +0100
commitd31f2307eee6e2a0f96342a58159d265ea03c58e (patch)
tree539454dff6a5b8e7908610e76fa597a25668439a /cli/tools/installer.rs
parent2dc37f411e8947d3c20cd93d1fa1937edc239499 (diff)
feat(install): require -g / --global flag (#23060)
In preparation for upcoming changes to `deno install` in Deno 2. If `-g` or `--global` flag is not provided a warning will be emitted: ``` ⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use `-g` or `--global` flag. ``` The same will happen for `deno uninstall` - unless `-g`/`--global` flag is provided a warning will be emitted. Towards https://github.com/denoland/deno/issues/23062 --------- Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r--cli/tools/installer.rs41
1 files changed, 38 insertions, 3 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs
index ea4b5ff48..1252c2faf 100644
--- a/cli/tools/installer.rs
+++ b/cli/tools/installer.rs
@@ -5,6 +5,7 @@ use crate::args::CaData;
use crate::args::Flags;
use crate::args::InstallFlags;
use crate::args::TypeCheckMode;
+use crate::args::UninstallFlags;
use crate::factory::CliFactory;
use crate::http_util::HttpClient;
use crate::util::fs::canonicalize_path_maybe_not_exists;
@@ -183,7 +184,13 @@ pub async fn infer_name_from_url(url: &Url) -> Option<String> {
Some(stem.to_string())
}
-pub fn uninstall(name: String, root: Option<String>) -> Result<(), AnyError> {
+pub fn uninstall(uninstall_flags: UninstallFlags) -> Result<(), AnyError> {
+ let name = uninstall_flags.name;
+ let root = uninstall_flags.root;
+
+ 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.");
+ }
let cwd = std::env::current_dir().context("Unable to get CWD")?;
let root = if let Some(root) = root {
canonicalize_path_maybe_not_exists(&cwd.join(root))?
@@ -241,6 +248,9 @@ pub async fn install_command(
flags: Flags,
install_flags: InstallFlags,
) -> Result<(), AnyError> {
+ 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.");
+ }
// ensure the module is cached
CliFactory::from_flags(flags.clone())?
.module_load_preparer()
@@ -663,6 +673,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -697,6 +708,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -725,6 +737,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -758,6 +771,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -786,6 +800,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -810,6 +825,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -836,6 +852,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -864,6 +881,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -897,6 +915,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -926,6 +945,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -956,6 +976,7 @@ mod tests {
name: None,
root: Some(temp_dir.to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -990,6 +1011,7 @@ mod tests {
name: None,
root: Some(env::temp_dir().to_string_lossy().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -1025,6 +1047,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -1054,6 +1077,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -1074,6 +1098,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await;
@@ -1095,6 +1120,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: true,
+ global: false,
},
)
.await;
@@ -1125,6 +1151,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: true,
+ global: false,
},
)
.await;
@@ -1154,6 +1181,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -1194,6 +1222,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: false,
+ global: false,
},
)
.await
@@ -1238,6 +1267,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: true,
+ global: false,
},
)
.await;
@@ -1280,6 +1310,7 @@ mod tests {
name: Some("echo_test".to_string()),
root: Some(temp_dir.path().to_string()),
force: true,
+ global: false,
},
)
.await;
@@ -1330,8 +1361,12 @@ mod tests {
File::create(file_path).unwrap();
}
- uninstall("echo_test".to_string(), Some(temp_dir.path().to_string()))
- .unwrap();
+ uninstall(UninstallFlags {
+ name: "echo_test".to_string(),
+ root: Some(temp_dir.path().to_string()),
+ global: false,
+ })
+ .unwrap();
assert!(!file_path.exists());
assert!(!file_path.with_extension("tsconfig.json").exists());