Skip to content

Commit

Permalink
create a child process to exit vit application on process kill
Browse files Browse the repository at this point in the history
  • Loading branch information
sumn2u committed Jul 16, 2024
1 parent 2e0ca3c commit 1740c42
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions client/client-server.js
Original file line number Diff line number Diff line change
@@ -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();
});
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"scripts": {
"start": "vite --force",
"windows-start": "node client-server.js",
"build": "vite build",
"test": "jest",
"format": "prettier --write ."
Expand Down

0 comments on commit 1740c42

Please sign in to comment.