diff --git a/scripts/desktop-tauri-build.mjs b/scripts/desktop-tauri-build.mjs index fdd9e673..77b46ad9 100644 --- a/scripts/desktop-tauri-build.mjs +++ b/scripts/desktop-tauri-build.mjs @@ -30,7 +30,9 @@ async function main() { // Tauri CLI reads CI and rejects numeric "1" (common in CI providers). process.env.CI = 'true'; - const r = spawnSync('pnpm', ['exec', 'tauri', 'build', ...forward], { + const tauriConfig = join(desktopDir, 'tauri.conf.json'); + const tauriBin = join(ROOT, 'node_modules', '.bin', 'tauri'); + const r = spawnSync(tauriBin, ['build', '--config', tauriConfig, ...forward], { cwd: desktopDir, env: process.env, stdio: 'inherit', diff --git a/scripts/dev.cjs b/scripts/dev.cjs index c5174cb8..cb7b3a80 100644 --- a/scripts/dev.cjs +++ b/scripts/dev.cjs @@ -107,6 +107,29 @@ function runCommand(command, cwd = ROOT_DIR) { }); } +/** + * Spawn a command with explicit args array (no shell interpolation, safe for paths with spaces) + */ +function spawnCommand(cmd, args, cwd = ROOT_DIR) { + return new Promise((resolve, reject) => { + const child = spawn(cmd, args, { + cwd, + stdio: 'inherit', + shell: true, + }); + + child.on('close', (code) => { + if (code === 0) { + resolve(); + } else { + reject(new Error(`Command failed with code ${code}`)); + } + }); + + child.on('error', reject); + }); +} + /** * Main entry */ @@ -191,7 +214,10 @@ async function main() { process.exit(1); } } - await runCommand('pnpm exec tauri dev', path.join(ROOT_DIR, 'src/apps/desktop')); + const desktopDir = path.join(ROOT_DIR, 'src/apps/desktop'); + const tauriConfig = path.join(desktopDir, 'tauri.conf.json'); + const tauriBin = path.join(ROOT_DIR, 'node_modules', '.bin', 'tauri'); + await spawnCommand(tauriBin, ['dev', '--config', tauriConfig], desktopDir); } else { await runCommand('pnpm exec vite', path.join(ROOT_DIR, 'src/web-ui')); } diff --git a/src/apps/desktop/tauri.conf.json b/src/apps/desktop/tauri.conf.json index 4bdb3914..0335b048 100644 --- a/src/apps/desktop/tauri.conf.json +++ b/src/apps/desktop/tauri.conf.json @@ -3,7 +3,7 @@ "productName": "BitFun", "identifier": "com.bitfun.desktop", "build": { - "beforeDevCommand": "pnpm run type-check:web && pnpm run dev:web", + "beforeDevCommand": "pnpm run dev:web", "devUrl": "http://localhost:1422", "beforeBuildCommand": "pnpm run build:web && pnpm run prepare:mobile-web", "frontendDist": "../../../dist"