ff73fdf18c
- Added stdin: "ignore" to prevent stdin from being inherited by spawned process. - Removed windowsHide option which is not supported by Bun.spawn.
21 lines
549 B
TypeScript
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
|
|
}
|
|
}
|