UNPKG

react-email

Version:

A live preview of your emails right in your browser.

47 lines (36 loc) 857 B
import child_process from 'node:child_process'; import path from 'node:path'; import url from 'node:url'; import { join } from 'shlex'; const filename = url.fileURLToPath(import.meta.url); const dirname = path.dirname(filename); const root = path.resolve(dirname, '../src/cli/index.ts'); const tsx = child_process.spawn( `pnpm tsx ${root} ${join(process.argv.slice(2))}`, { cwd: process.cwd(), shell: true, stdio: 'inherit', }, ); tsx.on('close', (code) => { process.exit(code); }); process.on('uncaughtExceptionMonitor', () => { tsx.kill(); }); process.on('exit', (code) => { tsx.kill(code); }); process.on('SIGINT', () => { tsx.kill('SIGINT'); }); process.on('SIGTERM', () => { tsx.kill('SIGTERM'); }); process.on('SIGUSR1', () => { tsx.kill('SIGUSR1'); }); process.on('SIGUSR2', () => { tsx.kill('SIGUSR2'); });