Files
oh-my-pi/packages/coding-agent/src/utils/open.ts
T
can1357 ff73fdf18c fix(coding-agent/utils): fixed Bun.spawn options for opening paths
- Added stdin: "ignore" to prevent stdin from being inherited by spawned process.
- Removed windowsHide option which is not supported by Bun.spawn.
2026-03-03 04:16:17 +01:00

21 lines
549 B
TypeScript

/** Open a URL or file path in the default browser/application. Best-effort, never throws. */
export function openPath(urlOrPath: string): void {
let cmd: string[];
switch (process.platform) {
case "darwin":
cmd = ["open", urlOrPath];
break;
case "win32":
cmd = ["rundll32", "url.dll,FileProtocolHandler", urlOrPath];
break;
default:
cmd = ["xdg-open", urlOrPath];
break;
}
try {
Bun.spawn(cmd, { stdin: "ignore", stdout: "ignore", stderr: "ignore" });
} catch {
// Best-effort: browser opening is non-critical
}
}