-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.js
More file actions
45 lines (42 loc) · 1.25 KB
/
build.js
File metadata and controls
45 lines (42 loc) · 1.25 KB
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
44
45
const child = require('child_process')
const fs = require('fs')
function buildAll() {
const json = JSON.parse(fs.readFileSync("./angular.json").toString());
const errors = Object.keys(json.projects)
.reduce((arr, project) => {
const proj = json.projects[project];
let build = proj.architect && proj.architect.build;
if (build) {
arr = arr.concat(...Object.keys(build.configurations || {})
.map(config => ({ project, config }))
);
}
return arr;
}, [])
// Execute `ng build` and collect errors.
.reduce((err, exec) => {
try {
console.log(`Building ${exec.project} (${exec.config}):`);
child.execSync(`ng build --project ${exec.project} --configuration ${exec.config}`, { stdio: "inherit" });
}
catch (error) {
err.push({
project: exec.project,
config: exec.config,
message: error.message
});
}
console.log("\n");
return err;
}, []);
// Conditionally log errors
if (errors.length === 0)
console.log("Completed");
else {
console.log("\n");
errors.forEach(error => {
console.error(`Building ${error.project} (${error.config}) failed:\n\t${error.message}`);
});
}
}
buildAll();