Skip to content

Commit c787f74

Browse files
authored
fix(cli): only add -- to generated android template for npm (#6508)
1 parent d5ac76b commit c787f74

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

.changes/cli-pnpm.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'cli.rs': 'patch'
3+
'cli.js': 'patch'
4+
---
5+
6+
Fix android project build crashing when using `pnpm` caused by extra `--`.

tooling/cli/node/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2-
// SPDX-License-Identifier: Apache-2.0
3-
// SPDX-License-Identifier: MIT
4-
51
const { existsSync, readFileSync } = require('fs')
62
const { join } = require('path')
73

@@ -15,7 +11,8 @@ function isMusl() {
1511
// For Node 10
1612
if (!process.report || typeof process.report.getReport !== 'function') {
1713
try {
18-
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
14+
const lddPath = require('child_process').execSync('which ldd').toString().trim();
15+
return readFileSync(lddPath, 'utf8').includes('musl')
1916
} catch (e) {
2017
return true
2118
}
@@ -105,6 +102,15 @@ switch (platform) {
105102
}
106103
break
107104
case 'darwin':
105+
localFileExisted = existsSync(join(__dirname, 'cli.darwin-universal.node'))
106+
try {
107+
if (localFileExisted) {
108+
nativeBinding = require('./cli.darwin-universal.node')
109+
} else {
110+
nativeBinding = require('@tauri-apps/cli-darwin-universal')
111+
}
112+
break
113+
} catch {}
108114
switch (arch) {
109115
case 'x64':
110116
localFileExisted = existsSync(join(__dirname, 'cli.darwin-x64.node'))

tooling/cli/src/mobile/init.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,22 @@ pub fn exec(
124124
if r.is_match(&bin_stem) {
125125
if let Some(npm_execpath) = var_os("npm_execpath").map(PathBuf::from) {
126126
let manager_stem = npm_execpath.file_stem().unwrap().to_os_string();
127-
let manager = if manager_stem == "npm-cli" {
127+
binary = if manager_stem == "npm-cli" {
128128
"npm".into()
129129
} else {
130130
manager_stem
131131
};
132-
binary = manager;
133132
if !build_args.is_empty() {
134133
// remove script path, we'll use `npm_lifecycle_event` instead
135134
build_args.remove(0);
136135
}
137-
build_args.insert(0, "--".into());
136+
if binary == "npm" {
137+
build_args.insert(0, "--".into());
138+
}
138139
build_args.insert(0, var("npm_lifecycle_event").unwrap());
139-
build_args.insert(0, "run".into());
140+
if binary == "npm" {
141+
build_args.insert(0, "run".into());
142+
}
140143
}
141144
}
142145
map.insert("tauri-binary", binary.to_string_lossy());

0 commit comments

Comments
 (0)