Refactor Windows instance directory retrieval in deeplink handling
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good

- Updated the `getInstanceDir` function to use `os.homedir()` as a fallback for the local app data path, ensuring compatibility across different Windows environments.
- Improved code clarity by consolidating the logic for determining the local application data directory.
This commit is contained in:
Tom Butcher 2026-08-02 22:25:14 +01:00
parent 5f061f92eb
commit 1fdbb01ceb

View File

@ -6,6 +6,7 @@ import {
writeFileSync
} from 'node:fs'
import net from 'node:net'
import os from 'node:os'
import { join } from 'node:path'
export const PROTOCOL_PREFIX = 'farmcontrol://'
@ -18,10 +19,9 @@ const PIPE_RETRY_DELAY_MS = 100
export function getInstanceDir() {
if (process.platform === 'win32') {
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA
if (localAppData) {
return join(localAppData, 'com.tombutcher.farmcontrol', 'instance')
}
const localAppData =
process.env.LOCALAPPDATA || join(os.homedir(), 'AppData', 'Local')
return join(localAppData, 'com.tombutcher.farmcontrol', 'instance')
}
return join(process.env.TMPDIR || '/tmp', 'com.tombutcher.farmcontrol', 'instance')