farmcontrol-ui/src/bun/deeplink.js
Tom Butcher eb1ee1e82b
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
Update Windows installer to use FarmControl.exe and enhance process handling
- Replaced references to launcher.exe with FarmControl.exe in the installer script, ensuring consistency in application execution.
- Added taskkill command to stop running FarmControl processes during installation.
- Updated shortcut creation to point to FarmControl.exe for both desktop and start menu.
- Enhanced cleanup process to remove old executable backups and ensure proper application state after updates.
- Refactored updater logic to check for the presence of FarmControl.exe, improving application launch reliability.
2026-08-04 01:29:31 +01:00

51 lines
1.2 KiB
JavaScript

import { spawn } from 'node:child_process'
import { existsSync } from 'node:fs'
import { dirname, join } from 'node:path'
import {
buildDeeplinkPayload,
findProtocolUrl,
forwardDeeplinkToRunningInstance,
writeDeeplinkSignal
} from '../desktop/deeplink-ipc.js'
const url = findProtocolUrl(process.argv)
console.log('[deeplink] argv:', process.argv)
console.log('[deeplink] url:', url ?? null)
if (!url) {
process.exit(1)
}
const payload = buildDeeplinkPayload(url, process.argv)
const forwarded = await forwardDeeplinkToRunningInstance(payload)
if (forwarded) {
console.log('[deeplink] forwarded to running Farm Control instance')
process.exit(0)
}
console.log('[deeplink] no running instance found, launching Farm Control')
writeDeeplinkSignal(payload)
const binDir = dirname(process.execPath)
const launcherPath = ['FarmControl.exe', 'launcher.exe']
.map((name) => join(binDir, name))
.find((candidate) => existsSync(candidate))
if (!launcherPath) {
console.error('[deeplink] FarmControl.exe not found in', binDir)
process.exit(1)
}
const child = spawn(launcherPath, [], {
cwd: dirname(launcherPath),
detached: true,
stdio: 'ignore',
windowsHide: true
})
child.unref()
process.exit(0)