summaryrefslogtreecommitdiff
path: root/cli/tools/installer.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-05-08 20:34:46 +0100
committerGitHub <noreply@github.com>2024-05-08 12:34:46 -0700
commit4e23a5b1fc2ba0e26f1832a2c374a1f3aef9e7ff (patch)
tree4e71d07cce253b3a8035285e11999c1294643074 /cli/tools/installer.rs
parent525b3c8d746b8eb358ed6466cd4b68ebd6542392 (diff)
FUTURE: `deno install` changes (#23498)
This PR implements the changes we plan to make to `deno install` in deno 2.0. - `deno install` without arguments caches dependencies from `package.json` / `deno.json` and sets up the `node_modules` folder - `deno install <pkg>` adds the package to the config file (either `package.json` or `deno.json`), i.e. it aliases `deno add` - `deno add` can also add deps to `package.json` (this is gated behind `DENO_FUTURE` due to uncertainty around handling projects with both `deno.json` and `package.json`) - `deno install -g <bin>` installs a package as a globally available binary (the same as `deno install <bin>` in 1.0) --------- Co-authored-by: Nathan Whitaker <nathan@deno.com>
Diffstat (limited to 'cli/tools/installer.rs')
-rw-r--r--cli/tools/installer.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs
index f3eba7b8a..9ff17ccc3 100644
--- a/cli/tools/installer.rs
+++ b/cli/tools/installer.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use crate::args::resolve_no_prompt;
+use crate::args::AddFlags;
use crate::args::CaData;
use crate::args::Flags;
use crate::args::InstallFlags;
@@ -253,6 +254,20 @@ pub fn uninstall(uninstall_flags: UninstallFlags) -> Result<(), AnyError> {
Ok(())
}
+async fn install_local(
+ flags: Flags,
+ maybe_add_flags: Option<AddFlags>,
+) -> Result<(), AnyError> {
+ if let Some(add_flags) = maybe_add_flags {
+ return super::registry::add(flags, add_flags).await;
+ }
+
+ let factory = CliFactory::from_flags(flags)?;
+ crate::module_loader::load_top_level_deps(&factory).await?;
+
+ Ok(())
+}
+
pub async fn install_command(
flags: Flags,
install_flags: InstallFlags,
@@ -263,7 +278,9 @@ pub async fn install_command(
let install_flags_global = match install_flags.kind {
InstallKind::Global(flags) => flags,
- InstallKind::Local => unreachable!(),
+ InstallKind::Local(maybe_add_flags) => {
+ return install_local(flags, maybe_add_flags).await
+ }
};
// ensure the module is cached