Quellcode durchsuchen

fix(cli): `ios dev` and `ios build` support for `bun` (#10569)

Lucas Fernandes Nogueira vor 11 Monaten
Ursprung
Commit
712f1049fa
2 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen
  1. 6 0
      .changes/fix-ios-bun-support.md
  2. 5 2
      tooling/cli/src/mobile/ios/xcode_script.rs

+ 6 - 0
.changes/fix-ios-bun-support.md

@@ -0,0 +1,6 @@
+---
+"tauri-cli": patch:bug
+"@tauri-apps/cli": patch:bug
+---
+
+Fixes running `ios dev` and `ios build` using `bun`.

+ 5 - 2
tooling/cli/src/mobile/ios/xcode_script.rs

@@ -14,7 +14,7 @@ use clap::Parser;
 
 use std::{
   collections::HashMap,
-  env::{current_dir, set_current_dir, var_os},
+  env::{current_dir, set_current_dir, var, var_os},
   ffi::OsStr,
   path::{Path, PathBuf},
   process::Command,
@@ -62,7 +62,10 @@ pub fn command(options: Options) -> Result<()> {
   }
 
   // `xcode-script` is ran from the `gen/apple` folder when not using NPM.
-  if var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none() {
+  // so we must change working directory to the src-tauri folder to resolve the tauri dir
+  if (var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none())
+    || var("npm_config_user_agent").map_or(false, |agent| agent.starts_with("bun"))
+  {
     set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
   }