-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.js
32 lines (26 loc) · 985 Bytes
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs');
const { exec } = require('child_process');
const path = require('path');
const paths = ['./client', './api'];
paths.forEach((dirPath) => {
// Check if the directory exists
fs.access(dirPath, fs.constants.F_OK, (err) => {
if (err) {
console.error(`Directory ${dirPath} does not exist.`);
return;
}
console.log(`Directory ${dirPath} exists. Running npm start in a new terminal...`);
// Run npm start in a new Command Prompt window
exec(`start cmd.exe /K "cd ${dirPath} && npm start"`, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing npm start in ${dirPath}: ${error.message}`);
return;
}
if (stderr) {
console.error(`stderr in ${dirPath}: ${stderr}`);
return;
}
console.log(`stdout in ${dirPath}: ${stdout}`);
});
});
});