Files
oh-my-opencode/src/tools/interactive-bash/tmux-path-resolver.ts
T
YeonGyu-Kim 29155ec7bc refactor: wave 1 - extract leaf modules, rename catch-all files, split index.ts hooks
- Split 25+ index.ts files into hook.ts + extracted modules
- Rename all catch-all utils.ts/helpers.ts to domain-specific names
- Split src/tools/lsp/ into ~15 focused modules
- Split src/tools/delegate-task/ into ~18 focused modules
- Separate shared types from implementation
- 155 files changed, 60+ new files created
- All typecheck clean, 61 tests pass
2026-02-08 13:57:26 +09:00

72 lines
1.3 KiB
TypeScript

import { spawn } from "bun"
let tmuxPath: string | null = null
let initPromise: Promise<string | null> | null = null
async function findTmuxPath(): Promise<string | null> {
const isWindows = process.platform === "win32"
const cmd = isWindows ? "where" : "which"
try {
const proc = spawn([cmd, "tmux"], {
stdout: "pipe",
stderr: "pipe",
})
const exitCode = await proc.exited
if (exitCode !== 0) {
return null
}
const stdout = await new Response(proc.stdout).text()
const path = stdout.trim().split("\n")[0]
if (!path) {
return null
}
const verifyProc = spawn([path, "-V"], {
stdout: "pipe",
stderr: "pipe",
})
const verifyExitCode = await verifyProc.exited
if (verifyExitCode !== 0) {
return null
}
return path
} catch {
return null
}
}
export async function getTmuxPath(): Promise<string | null> {
if (tmuxPath !== null) {
return tmuxPath
}
if (initPromise) {
return initPromise
}
initPromise = (async () => {
const path = await findTmuxPath()
tmuxPath = path
return path
})()
return initPromise
}
export function getCachedTmuxPath(): string | null {
return tmuxPath
}
export function startBackgroundCheck(): void {
if (!initPromise) {
initPromise = getTmuxPath()
initPromise.catch(() => {})
}
}