|
@@ -13,10 +13,16 @@ declare let __RUST_CLI_VERSION__: string
|
|
|
|
|
|
const currentDirName = dirname(fileURLToPath(import.meta.url))
|
|
|
|
|
|
+interface Options {
|
|
|
+ cwd?: string
|
|
|
+}
|
|
|
+
|
|
|
export async function runOnRustCli(
|
|
|
command: string,
|
|
|
- args: string[]
|
|
|
+ args: string[],
|
|
|
+ options: Options = {}
|
|
|
): Promise<{ pid: number; promise: Promise<void> }> {
|
|
|
+ const cwd = options.cwd ?? process.cwd()
|
|
|
const targetPath = resolve(currentDirName, '../..')
|
|
|
const targetCliPath = join(
|
|
|
targetPath,
|
|
@@ -39,20 +45,10 @@ export async function runOnRustCli(
|
|
|
}
|
|
|
|
|
|
if (existsSync(targetCliPath)) {
|
|
|
- pid = spawn(
|
|
|
- targetCliPath,
|
|
|
- ['tauri', command, ...args],
|
|
|
- process.cwd(),
|
|
|
- onClose
|
|
|
- )
|
|
|
+ pid = spawn(targetCliPath, ['tauri', command, ...args], cwd, onClose)
|
|
|
} else if (process.env.NODE_ENV === 'production') {
|
|
|
await downloadCli()
|
|
|
- pid = spawn(
|
|
|
- targetCliPath,
|
|
|
- ['tauri', command, ...args],
|
|
|
- process.cwd(),
|
|
|
- onClose
|
|
|
- )
|
|
|
+ pid = spawn(targetCliPath, ['tauri', command, ...args], cwd, onClose)
|
|
|
} else {
|
|
|
if (existsSync(resolve(targetPath, 'test'))) {
|
|
|
// running local CLI since test directory exists
|
|
@@ -62,12 +58,7 @@ export async function runOnRustCli(
|
|
|
targetPath,
|
|
|
'../cli.rs/target/release/cargo-tauri'
|
|
|
)
|
|
|
- pid = spawn(
|
|
|
- localCliPath,
|
|
|
- ['tauri', command, ...args],
|
|
|
- process.cwd(),
|
|
|
- onClose
|
|
|
- )
|
|
|
+ pid = spawn(localCliPath, ['tauri', command, ...args], cwd, onClose)
|
|
|
} else {
|
|
|
spawnSync(
|
|
|
'cargo',
|
|
@@ -79,14 +70,9 @@ export async function runOnRustCli(
|
|
|
'--version',
|
|
|
__RUST_CLI_VERSION__
|
|
|
],
|
|
|
- process.cwd()
|
|
|
- )
|
|
|
- pid = spawn(
|
|
|
- targetCliPath,
|
|
|
- ['tauri', command, ...args],
|
|
|
- process.cwd(),
|
|
|
- onClose
|
|
|
+ cwd
|
|
|
)
|
|
|
+ pid = spawn(targetCliPath, ['tauri', command, ...args], cwd, onClose)
|
|
|
}
|
|
|
}
|
|
|
|