Files
orca/src/main/hook-runtime-target.ts
T
OrcaWinandOrcaWin 4935d75e1c [comment audit] Shorten top-level main process H–K comments (#32290)
* chore: shorten process-host comments

* chore: audit CLI parsing and host-routing comments

* chore: remove stale host-selector restriction comment

* chore: shorten remaining CLI root comments

* Shorten CLI handler comments

* Shorten CLI runtime and command specification comments

* Shorten top-level main process A–G comments

* [comment audit] Shorten main process H–K comments

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-23 09:50:47 -07:00

49 lines
1.3 KiB
TypeScript

import { parseWslPath, toLinuxPath } from './wsl'
import type { ProjectExecutionRuntimeResolution } from '../shared/project-execution-runtime'
export type HookRuntimeTarget = {
wslDistro?: string | null
}
export function getHookRuntimeTarget(
projectRuntime?: ProjectExecutionRuntimeResolution | HookRuntimeTarget
): HookRuntimeTarget | undefined {
if (!projectRuntime) {
return undefined
}
if ('status' in projectRuntime) {
if (projectRuntime.status === 'repair-required') {
return projectRuntime.repair.preferredRuntime.kind === 'wsl'
? { wslDistro: projectRuntime.repair.preferredRuntime.distro }
: undefined
}
return projectRuntime.runtime.kind === 'wsl'
? { wslDistro: projectRuntime.runtime.distro }
: undefined
}
return projectRuntime.wslDistro ? { wslDistro: projectRuntime.wslDistro } : undefined
}
export function getHookWslContext(
cwd: string,
runtimeTarget?: HookRuntimeTarget
): { distro: string | null; linuxPath: string } | null {
const pathInfo = parseWslPath(cwd)
if (pathInfo) {
return pathInfo
}
const wslDistro = runtimeTarget?.wslDistro?.trim()
if (!wslDistro) {
return null
}
// Project runtime may route a Windows checkout through WSL; hooks need its Linux path.
return {
distro: wslDistro,
linuxPath: toLinuxPath(cwd)
}
}