20 lines
713 B
TypeScript
20 lines
713 B
TypeScript
/** Runs the Tauri CLI of this package, in this package's folder, and stops the script if it fails. */
|
|
import { spawnSync } from 'node:child_process';
|
|
import { dirname, join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
export const PACKAGE = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
export const SRC_TAURI = join(PACKAGE, 'src-tauri');
|
|
|
|
export function tauri(...args: string[]): void {
|
|
const run = spawnSync('pnpm', ['exec', 'tauri', ...args], {
|
|
cwd: PACKAGE,
|
|
stdio: 'inherit',
|
|
shell: process.platform === 'win32'
|
|
});
|
|
if (run.status !== 0) {
|
|
console.error(`tauri ${args.join(' ')} failed (exit ${String(run.status ?? run.signal)})`);
|
|
process.exit(1);
|
|
}
|
|
}
|