24 lines
651 B
JavaScript
24 lines
651 B
JavaScript
import { execSync } from "node:child_process"
|
|
import { platform } from "node:os"
|
|
|
|
const url = process.argv[2] || "http://localhost:3001/splash"
|
|
|
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
|
|
|
|
async function main() {
|
|
await sleep(8000)
|
|
try {
|
|
if (platform() === "win32") {
|
|
execSync(`start "" "${url}"`, { stdio: "ignore", timeout: 5000 })
|
|
} else if (platform() === "darwin") {
|
|
execSync(`open "${url}"`, { stdio: "ignore", timeout: 5000 })
|
|
} else {
|
|
execSync(`xdg-open "${url}"`, { stdio: "ignore", timeout: 5000 })
|
|
}
|
|
} catch (e) {
|
|
console.error("Failed to open browser:", e.message)
|
|
}
|
|
}
|
|
|
|
main()
|