mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(cli): mobile init when using pnpm dlx (#14118)
i noticed this when testing #13180 (though the original issue refers to npx, which I could not reproduce yet)
This commit is contained in:
committed by
GitHub
parent
b0012424c5
commit
abf7e8850b
6
.changes/mobile-pnpm-dlx-init.md
Normal file
6
.changes/mobile-pnpm-dlx-init.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@tauri-apps/cli": patch:bug
|
||||
"tauri-cli": patch:bug
|
||||
---
|
||||
|
||||
Fixes mobile project initialization when using `pnpx` or `pnpm dlx`.
|
||||
@@ -79,6 +79,8 @@ pub fn exec(
|
||||
if r.is_match(&bin_stem.to_string_lossy()) {
|
||||
if var_os("PNPM_PACKAGE_NAME").is_some() {
|
||||
return ("pnpm".into(), build_args);
|
||||
} else if is_pnpm_dlx() {
|
||||
return ("pnpm".into(), vec!["dlx", "@tauri-apps/cli"]);
|
||||
} else if let Some(npm_execpath) = var_os("npm_execpath") {
|
||||
let manager_stem = PathBuf::from(&npm_execpath)
|
||||
.file_stem()
|
||||
@@ -368,3 +370,17 @@ fn unprefix_path(
|
||||
)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
fn is_pnpm_dlx() -> bool {
|
||||
var_os("NODE_PATH")
|
||||
.map(PathBuf::from)
|
||||
.is_some_and(|node_path| {
|
||||
let mut iter = node_path.components().peekable();
|
||||
while let Some(c) = iter.next() {
|
||||
if c.as_os_str() == "pnpm" && iter.peek().is_some_and(|c| c.as_os_str() == "dlx") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user