Kode-cli/src/utils/browser.ts
2025-08-10 19:57:17 +08:00

15 lines
384 B
TypeScript

import { execFileNoThrow } from './execFileNoThrow'
export async function openBrowser(url: string): Promise<boolean> {
const platform = process.platform
const command =
platform === 'win32' ? 'start' : platform === 'darwin' ? 'open' : 'xdg-open'
try {
const { code } = await execFileNoThrow(command, [url])
return code === 0
} catch (_) {
return false
}
}