-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
43 lines (36 loc) · 1.1 KB
/
build.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
32
33
34
35
36
37
38
39
40
41
42
43
import { exec } from "child_process";
const fs = require("fs");
const path = require("path");
const { terminal } = require("./terminal/Terminal");
const config = {
excludeDirs: [".git", "node_modules", "docs"],
currentDir: path.join(__dirname, "./"),
};
fs.readdir(
config.currentDir,
{ withFileTypes: true },
(error: any, files: any) => {
files = files.filter((file: any) =>
fs.statSync(path.join(config.currentDir, file.name)).isDirectory()
);
let filesTemp = [] as any[];
files.forEach((file: any) => {
if (!config.excludeDirs.includes(file.name)) {
filesTemp.push(file.name);
}
});
files = filesTemp;
terminal.log("The following projects will be built:");
files.forEach((file: any) => terminal.log(" - " + file));
files.forEach((file: string) => {
process.chdir(path.join(config.currentDir, file));
const proc = exec("npm i | npx rollup -c");
proc.stdout?.on("data", (data) =>
terminal.log("[ " + file + " ] >_" + data.replace("\n", ""))
);
proc.stderr?.on("data", (data) =>
terminal.log("[ " + file + " ] >_" + data.replace("\n", ""))
);
});
}
);