2022-06-15 20:23:26 +02:00
|
|
|
import {spawn} from 'child_process'
|
|
|
|
|
|
|
|
export function openForOS(hostedAt: string) {
|
|
|
|
const open = {
|
2022-11-22 16:05:11 +01:00
|
|
|
darwin: ['open', '-a', 'Google Chrome'],
|
2022-06-15 20:23:26 +02:00
|
|
|
linux: ['xdg-open'],
|
|
|
|
win32: ['cmd', '/c', 'start'],
|
|
|
|
}
|
|
|
|
const platform = process.platform as keyof typeof open
|
|
|
|
if (open[platform]) {
|
|
|
|
spawn(open[platform][0], [...open[platform].slice(1), hostedAt])
|
|
|
|
} else {
|
|
|
|
console.error(
|
|
|
|
`Failed to open (${hostedAt}) for unconfigured platform (${platform})`,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|