From 7af01ff2ce623d727cd13a4c8a549c1c80031882 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Tue, 5 Nov 2024 19:16:32 +0200 Subject: [PATCH] fix(cli): fix `tauri migrate` failing to install NPM deps when running from Deno (#11523) * fix(cli): fix `tauri migrate` failing to install NPM deps when running from Deno * clippy --- .changes/cli-migrate-deno.md | 7 +++++++ crates/tauri-cli/src/add.rs | 5 +---- crates/tauri-cli/src/helpers/npm.rs | 13 +++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .changes/cli-migrate-deno.md diff --git a/.changes/cli-migrate-deno.md b/.changes/cli-migrate-deno.md new file mode 100644 index 000000000000..63e58dcfdb3f --- /dev/null +++ b/.changes/cli-migrate-deno.md @@ -0,0 +1,7 @@ +--- +"tauri-cli": "patch:bug" +"@tauri-apps/cli": "patch:bug" +--- + +Fix `tauri migrate` failing to install NPM depenencies when running from Deno. + diff --git a/crates/tauri-cli/src/add.rs b/crates/tauri-cli/src/add.rs index f02771d97fe3..56ad58ef0495 100644 --- a/crates/tauri-cli/src/add.rs +++ b/crates/tauri-cli/src/add.rs @@ -90,10 +90,7 @@ pub fn run(options: Options) -> Result<()> { })); let npm_spec = match (npm_version_req, options.tag, options.rev, options.branch) { - (Some(version_req), _, _, _) => match manager { - PackageManager::Deno => format!("npm:{npm_name}@{version_req}"), - _ => format!("{npm_name}@{version_req}"), - }, + (Some(version_req), _, _, _) => format!("{npm_name}@{version_req}"), (None, Some(tag), None, None) => { format!("tauri-apps/tauri-plugin-{plugin}#{tag}") } diff --git a/crates/tauri-cli/src/helpers/npm.rs b/crates/tauri-cli/src/helpers/npm.rs index d1591f78dfdb..1189aa323a52 100644 --- a/crates/tauri-cli/src/helpers/npm.rs +++ b/crates/tauri-cli/src/helpers/npm.rs @@ -122,10 +122,15 @@ impl PackageManager { .join(", ") ); - let status = self - .cross_command() - .arg("add") - .args(dependencies) + let mut command = self.cross_command(); + command.arg("add"); + + match self { + PackageManager::Deno => command.args(dependencies.iter().map(|d| format!("npm:{d}"))), + _ => command.args(dependencies), + }; + + let status = command .current_dir(frontend_dir) .status() .with_context(|| format!("failed to run {self}"))?;