forked from baizeteam/baize-quick-study
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.ts
31 lines (25 loc) · 764 Bytes
/
start.ts
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
import { exec } from "child_process";
const { START_ENV } = process.env;
// 项目列表
export const siteList = ["main", "react", "vue3"];
export function runCommand(command) {
return new Promise((resolve, reject) => {
const childProcess = exec(command, (error, stdout, stderr) => {
if (error) {
reject(error);
} else {
resolve({ stdout, stderr });
}
});
childProcess.stdout?.pipe(process.stdout);
childProcess.stderr?.pipe(process.stderr);
});
}
const commands = siteList.map((site) => runCommand(`cd site/${site} && npm run ${START_ENV}`));
Promise.all(commands)
.then((results) => {
// console.log("done!-------", results);
})
.catch((err) => {
console.log("failed!------", err);
});