Skip to content

fix: Tauri setup command errors with string escaping on Windows with Bun #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 42 additions & 18 deletions apps/cli/src/helpers/setup/tauri-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,55 @@ export async function setupTauri(config: ProjectConfig): Promise<void> {
? "../build/client"
: "../dist";

const tauriArgs = [
const isWindows = process.platform === "win32";

const appName = path.basename(projectDir);

const commonArgs = [
"init",
`--app-name=${path.basename(projectDir)}`,
`--window-title=${path.basename(projectDir)}`,
`--app-name=${appName}`,
`--window-title=${appName}`,
`--frontend-dist=${frontendDist}`,
`--dev-url=${devUrl}`,
`--before-dev-command=\"${packageManager} run dev\"`,
`--before-build-command=\"${packageManager} run build\"`,
];
const tauriArgsString = tauriArgs.join(" ");

const commandWithArgs = `@tauri-apps/cli@latest ${tauriArgsString}`;
if (isWindows && packageManager === "bun") {
const baseCommand = getPackageExecutionCommand(
packageManager,
"@tauri-apps/cli@latest",
);
const [executable, ...baseArgs] = baseCommand.split(" ");

const tauriInitCommand = getPackageExecutionCommand(
packageManager,
commandWithArgs,
);
const tauriArgs = [
...baseArgs,
...commonArgs,
`--before-dev-command="${packageManager} run dev"`,
`--before-build-command="${packageManager} run build"`,
];

await execa(tauriInitCommand, {
cwd: clientPackageDir,
env: {
CI: "true",
},
shell: true,
});
await execa(executable, tauriArgs, {
cwd: clientPackageDir,
env: { CI: "true" },
});
} else {
const tauriArgs = [
...commonArgs,
`--before-dev-command=\"${packageManager} run dev\"`,
`--before-build-command=\"${packageManager} run build\"`,
];

const commandWithArgs = `@tauri-apps/cli@latest ${tauriArgs.join(" ")}`;
const tauriInitCommand = getPackageExecutionCommand(
packageManager,
commandWithArgs,
);

await execa(tauriInitCommand, {
cwd: clientPackageDir,
env: { CI: "true" },
shell: true,
});
}

s.stop("Tauri desktop app support configured successfully!");
} catch (error) {
Expand Down