Skip to content

Commit 4847b87

Browse files
fix(cli): handle npx for mobile commands, closes #7209 (#7218)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
1 parent 535f223 commit 4847b87

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

.changes/cli-npx-mobile.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri-cli': 'patch:bug'
3+
'@tauri-apps/cli': 'patch:bug'
4+
---
5+
6+
Fix `tauri (android|ios) (dev|build)` failing when using `npx tauri`

tooling/cli/node/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function isMusl() {
2121
// For Node 10
2222
if (!process.report || typeof process.report.getReport !== 'function') {
2323
try {
24-
const lddPath = require('child_process').execSync('which ldd').toString().trim();
24+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
2525
return readFileSync(lddPath, 'utf8').includes('musl')
2626
} catch (e) {
2727
return true

tooling/cli/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub fn setup(options: &mut Options, mobile: bool) -> Result<AppInterface> {
269269
.any(|ch| !(ch.is_alphanumeric() || ch == '-' || ch == '.'))
270270
{
271271
error!(
272-
"The bundle identifier \"{}\" set in `{} > tauri > bundle > identifier`. The bundle identifier string must contain only alphanumeric characters (AZ, az, and 09), hyphens (-), and periods (.).",
272+
"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 (.).",
273273
config_.tauri.bundle.identifier,
274274
bundle_identifier_source
275275
);

tooling/cli/src/mobile/init.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,26 @@ pub fn exec(
130130
if r.is_match(&bin_stem) {
131131
if let Some(npm_execpath) = var_os("npm_execpath").map(PathBuf::from) {
132132
let manager_stem = npm_execpath.file_stem().unwrap().to_os_string();
133-
binary = if manager_stem == "npm-cli" {
133+
let is_npm = manager_stem == "npm-cli";
134+
let is_npx = manager_stem == "npx-cli";
135+
binary = if is_npm {
134136
"npm".into()
137+
} else if is_npx {
138+
"npx".into()
135139
} else {
136140
manager_stem
137141
};
138-
if !build_args.is_empty() {
142+
if !(build_args.is_empty() || is_npx) {
139143
// remove script path, we'll use `npm_lifecycle_event` instead
140144
build_args.remove(0);
141145
}
142-
if binary == "npm" {
146+
if is_npm {
143147
build_args.insert(0, "--".into());
144148
}
145-
build_args.insert(0, var("npm_lifecycle_event").unwrap());
146-
if binary == "npm" {
149+
if !is_npx {
150+
build_args.insert(0, var("npm_lifecycle_event").unwrap());
151+
}
152+
if is_npm {
147153
build_args.insert(0, "run".into());
148154
}
149155
}

0 commit comments

Comments
 (0)