|
@@ -19,14 +19,17 @@ use tauri_mobile::{
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-use std::{env::current_dir, path::PathBuf};
|
|
|
+use std::{
|
|
|
+ env::{current_dir, var, var_os},
|
|
|
+ path::PathBuf,
|
|
|
+};
|
|
|
|
|
|
pub fn command(target: Target, ci: bool, reinstall_deps: bool) -> Result<()> {
|
|
|
let wrapper = TextWrapper::with_splitter(textwrap::termwidth(), textwrap::NoHyphenation);
|
|
|
exec(
|
|
|
target,
|
|
|
&wrapper,
|
|
|
- ci || std::env::var("CI").is_ok(),
|
|
|
+ ci || var_os("CI").is_some(),
|
|
|
reinstall_deps,
|
|
|
)
|
|
|
.map_err(|e| anyhow::anyhow!("{:#}", e))?;
|
|
@@ -85,7 +88,7 @@ pub fn exec(
|
|
|
let (handlebars, mut map) = handlebars(&app);
|
|
|
|
|
|
let mut args = std::env::args_os();
|
|
|
- let tauri_binary = args
|
|
|
+ let mut binary = args
|
|
|
.next()
|
|
|
.map(|bin| {
|
|
|
let path = PathBuf::from(&bin);
|
|
@@ -114,7 +117,28 @@ pub fn exec(
|
|
|
}
|
|
|
}
|
|
|
build_args.push(target.ide_build_script_name().into());
|
|
|
- map.insert("tauri-binary", tauri_binary.to_string_lossy());
|
|
|
+
|
|
|
+ let binary_path = PathBuf::from(&binary);
|
|
|
+ let bin_stem = binary_path.file_stem().unwrap().to_string_lossy();
|
|
|
+ let r = regex::Regex::new("(nodejs|node)([1-9]*)*$").unwrap();
|
|
|
+ if r.is_match(&bin_stem) {
|
|
|
+ if let Some(npm_execpath) = var_os("npm_execpath").map(PathBuf::from) {
|
|
|
+ let manager_stem = npm_execpath.file_stem().unwrap().to_os_string();
|
|
|
+ let manager = if manager_stem == "npm-cli" {
|
|
|
+ "npm".into()
|
|
|
+ } else {
|
|
|
+ manager_stem
|
|
|
+ };
|
|
|
+ binary = manager;
|
|
|
+ if !build_args.is_empty() {
|
|
|
+ // remove script path, we'll use `npm_lifecycle_event` instead
|
|
|
+ build_args.remove(0);
|
|
|
+ }
|
|
|
+ build_args.insert(0, var("npm_lifecycle_event").unwrap());
|
|
|
+ build_args.insert(0, "run".into());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.insert("tauri-binary", binary.to_string_lossy());
|
|
|
map.insert("tauri-binary-args", &build_args);
|
|
|
map.insert("tauri-binary-args-str", build_args.join(" "));
|
|
|
|