Skip to content

Commit

Permalink
fix(cli): handle npx for mobile commands, closes #7209 (#7218)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
amrbashir and lucasfernog authored Jun 16, 2023
1 parent 535f223 commit 4847b87
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-npx-mobile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---

Fix `tauri (android|ios) (dev|build)` failing when using `npx tauri`
2 changes: 1 addition & 1 deletion tooling/cli/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process').execSync('which ldd').toString().trim();
const lddPath = require('child_process').execSync('which ldd').toString().trim()
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub fn setup(options: &mut Options, mobile: bool) -> Result<AppInterface> {
.any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.'))
{
error!(
"The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-), and periods (.).",
"The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-), and periods (.).",
config_.tauri.bundle.identifier,
bundle_identifier_source
);
Expand Down
16 changes: 11 additions & 5 deletions tooling/cli/src/mobile/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,26 @@ pub fn exec(
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();
binary = if manager_stem == "npm-cli" {
let is_npm = manager_stem == "npm-cli";
let is_npx = manager_stem == "npx-cli";
binary = if is_npm {
"npm".into()
} else if is_npx {
"npx".into()
} else {
manager_stem
};
if !build_args.is_empty() {
if !(build_args.is_empty() || is_npx) {
// remove script path, we'll use `npm_lifecycle_event` instead
build_args.remove(0);
}
if binary == "npm" {
if is_npm {
build_args.insert(0, "--".into());
}
build_args.insert(0, var("npm_lifecycle_event").unwrap());
if binary == "npm" {
if !is_npx {
build_args.insert(0, var("npm_lifecycle_event").unwrap());
}
if is_npm {
build_args.insert(0, "run".into());
}
}
Expand Down

0 comments on commit 4847b87

Please sign in to comment.