Skip to content

Commit 2aa4116

Browse files
committed
add 'run' back into 'npm run build' and read build args from env
1 parent 290ee3b commit 2aa4116

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

packages/@apphosting/adapter-angular/src/bin/build.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,38 @@ import {
1010

1111
const root = process.cwd();
1212

13-
// Determine which build runner to use
14-
let cmd = process.env.MONOREPO_COMMAND || DEFAULT_COMMAND;
13+
// TODO(blidd-google): Refactor monorepo logic into separate module
1514

16-
// Read environment variable (only relevant for monorepos with multiple targets)
17-
let target = process.env.MONOREPO_PROJECT || "";
15+
// Determine which project in a monorepo to build. The environment variable will only exist when
16+
// a monorepo has been detected in the parent buildpacks, so it can also be used to determine
17+
// whether the project we are building is in a monorepo setup.
18+
const project = process.env.MONOREPO_PROJECT || "";
1819

1920
// Determine root of project to build.
2021
let projectRoot = root;
2122
// N.B. We don't want to change directories for monorepo builds, so that the build process can
2223
// locate necessary files outside the project directory (e.g. at the root).
23-
if (process.env.FIREBASE_APP_DIRECTORY && !target) {
24+
if (process.env.FIREBASE_APP_DIRECTORY && !project) {
2425
projectRoot = projectRoot.concat("/", process.env.FIREBASE_APP_DIRECTORY);
2526
}
2627

28+
// Determine which command to run the build
29+
const cmd = process.env.MONOREPO_COMMAND || DEFAULT_COMMAND;
30+
31+
// Parse args to pass to the build command
32+
let cmdArgs: string[] = [];
33+
if (process.env.MONOREPO_BUILD_ARGS) {
34+
cmdArgs = process.env.MONOREPO_BUILD_ARGS.split(",");
35+
}
36+
2737
// Check build conditions, which vary depending on your project structure (standalone or monorepo)
28-
if (target) {
29-
checkMonorepoBuildConditions(cmd, target);
38+
if (project) {
39+
checkMonorepoBuildConditions(cmd, project);
3040
} else {
3141
await checkStandaloneBuildConditions(projectRoot);
3242
}
3343

34-
const outputBundleOptions = await build(projectRoot, cmd, target);
44+
const outputBundleOptions = await build(projectRoot, cmd, ...cmdArgs);
3545
await generateOutputDirectory(root, outputBundleOptions);
3646

3747
await validateOutputDirectory(outputBundleOptions);

packages/@apphosting/adapter-angular/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const build = (
111111
new Promise((resolve, reject) => {
112112
// enable JSON build logs for application builder
113113
process.env.NG_BUILD_LOGS_JSON = "1";
114-
const childProcess = spawn(cmd, ["build", ...argv], {
114+
const childProcess = spawn(cmd, ["run", "build", ...argv], {
115115
cwd: projectRoot,
116116
shell: true,
117117
stdio: ["inherit", "pipe", "pipe"],

0 commit comments

Comments
 (0)