Refactor Windows instance directory retrieval in deeplink handling
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
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:
parent
5f061f92eb
commit
1fdbb01ceb
@ -6,6 +6,7 @@ import {
|
|||||||
writeFileSync
|
writeFileSync
|
||||||
} from 'node:fs'
|
} from 'node:fs'
|
||||||
import net from 'node:net'
|
import net from 'node:net'
|
||||||
|
import os from 'node:os'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
|
|
||||||
export const PROTOCOL_PREFIX = 'farmcontrol://'
|
export const PROTOCOL_PREFIX = 'farmcontrol://'
|
||||||
@ -18,11 +19,10 @@ const PIPE_RETRY_DELAY_MS = 100
|
|||||||
|
|
||||||
export function getInstanceDir() {
|
export function getInstanceDir() {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
const localAppData = process.env.LOCALAPPDATA || process.env.APPDATA
|
const localAppData =
|
||||||
if (localAppData) {
|
process.env.LOCALAPPDATA || join(os.homedir(), 'AppData', 'Local')
|
||||||
return join(localAppData, 'com.tombutcher.farmcontrol', 'instance')
|
return join(localAppData, 'com.tombutcher.farmcontrol', 'instance')
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return join(process.env.TMPDIR || '/tmp', 'com.tombutcher.farmcontrol', 'instance')
|
return join(process.env.TMPDIR || '/tmp', 'com.tombutcher.farmcontrol', 'instance')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user