Skip to content

Commit

Permalink
fix(cli): only add -- to generated android template for npm (#6508)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Mar 21, 2023
1 parent d5ac76b commit c787f74
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changes/cli-pnpm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'cli.rs': 'patch'
'cli.js': 'patch'
---

Fix android project build crashing when using `pnpm` caused by extra `--`.
16 changes: 11 additions & 5 deletions tooling/cli/node/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

const { existsSync, readFileSync } = require('fs')
const { join } = require('path')

Expand All @@ -15,7 +11,8 @@ function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')
const lddPath = require('child_process').execSync('which ldd').toString().trim();
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true
}
Expand Down Expand Up @@ -105,6 +102,15 @@ switch (platform) {
}
break
case 'darwin':
localFileExisted = existsSync(join(__dirname, 'cli.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./cli.darwin-universal.node')
} else {
nativeBinding = require('@tauri-apps/cli-darwin-universal')
}
break
} catch {}
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'cli.darwin-x64.node'))
Expand Down
11 changes: 7 additions & 4 deletions tooling/cli/src/mobile/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,22 @@ 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();
let manager = if manager_stem == "npm-cli" {
binary = 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, "--".into());
if binary == "npm" {
build_args.insert(0, "--".into());
}
build_args.insert(0, var("npm_lifecycle_event").unwrap());
build_args.insert(0, "run".into());
if binary == "npm" {
build_args.insert(0, "run".into());
}
}
}
map.insert("tauri-binary", binary.to_string_lossy());
Expand Down

0 comments on commit c787f74

Please sign in to comment.