Commit | Line | Data |
---|---|---|
5480a636 AE |
1 | const childProcess = require("child_process"); |
2 | const fs = require("fs"); | |
3 | ||
4 | if (process.argv.length !== 3) { | |
5 | throw new Error("Requires the base path as argument."); | |
6 | } | |
7 | ||
8 | const basePath = process.argv[2]; | |
9 | if (!basePath.match(/[\\\/]$/)) { | |
10 | throw new Error("Path must end with a slash - any slash will do."); | |
11 | } | |
12 | else if (!fs.existsSync(basePath)) { | |
13 | throw new Error(`Invalid path, '${basePath}' does not exist or is not readable.`); | |
14 | } | |
15 | ||
16 | fs.readdirSync(basePath) | |
17 | .filter(directory => { | |
18 | if (directory.indexOf('.') !== 0 && fs.statSync(basePath + directory).isDirectory()) { | |
19 | // filter by known repository name patterns | |
20 | if (directory === "WCF" || directory.indexOf("com.woltlab.") === 0) { | |
21 | return true; | |
22 | } | |
23 | } | |
24 | ||
25 | return false; | |
26 | }) | |
27 | .forEach(directory => { | |
28 | console.log(`##### Building ${directory} #####\n`); | |
29 | ||
30 | let path = basePath + directory; | |
31 | if (directory === "WCF") { | |
32 | childProcess.execSync(`node _buildCore.js`, { | |
33 | stdio: [0, 1, 2] | |
34 | }); | |
35 | } | |
36 | else { | |
37 | childProcess.execSync(`node _buildExternal.js ${path}`, { | |
38 | stdio: [0, 1, 2] | |
39 | }); | |
40 | } | |
3f4a49f8 AE |
41 | |
42 | childProcess.execSync(`ts-node syncTemplates.ts ${path}`, { | |
43 | stdio: [0, 1, 2] | |
44 | }); | |
45 | ||
5480a636 | 46 | console.log("\n"); |
3f4a49f8 | 47 | }); |