theatre/packages/playground/devEnv/openForOS.ts
Andrew Prifer e3a194c7dd
Playground improvements (#342)
Remove previews, add vs code task, open in chrome
2022-11-22 15:05:11 +00:00

17 lines
479 B
TypeScript

import {spawn} from 'child_process'
export function openForOS(hostedAt: string) {
const open = {
darwin: ['open', '-a', 'Google Chrome'],
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})`,
)
}
}