From 1740c42c1049ed7c6327a014bc03881b3d0964ce Mon Sep 17 00:00:00 2001 From: sumn2u Date: Tue, 16 Jul 2024 08:35:30 -0500 Subject: [PATCH] create a child process to exit vit application on process kill --- client/client-server.js | 17 +++++++++++++++++ client/package.json | 1 + 2 files changed, 18 insertions(+) create mode 100644 client/client-server.js diff --git a/client/client-server.js b/client/client-server.js new file mode 100644 index 0000000..729c639 --- /dev/null +++ b/client/client-server.js @@ -0,0 +1,17 @@ +import { exec } from 'child_process'; + +const vite = exec('npx vite'); + +vite.stdout.on('data', (data) => { + console.log(data.toString()); +}); + +vite.stderr.on('data', (data) => { + console.error(data.toString()); +}); + +process.on('SIGINT', () => { + console.log('Killing Vite process'); + vite.kill('SIGINT'); + process.exit(); +}); diff --git a/client/package.json b/client/package.json index a31739d..73da882 100644 --- a/client/package.json +++ b/client/package.json @@ -47,6 +47,7 @@ }, "scripts": { "start": "vite --force", + "windows-start": "node client-server.js", "build": "vite build", "test": "jest", "format": "prettier --write ."