@@ -10,28 +10,38 @@ import {
10
10
11
11
const root = process . cwd ( ) ;
12
12
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
15
14
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 || "" ;
18
19
19
20
// Determine root of project to build.
20
21
let projectRoot = root ;
21
22
// N.B. We don't want to change directories for monorepo builds, so that the build process can
22
23
// 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 ) {
24
25
projectRoot = projectRoot . concat ( "/" , process . env . FIREBASE_APP_DIRECTORY ) ;
25
26
}
26
27
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
+
27
37
// 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 ) ;
30
40
} else {
31
41
await checkStandaloneBuildConditions ( projectRoot ) ;
32
42
}
33
43
34
- const outputBundleOptions = await build ( projectRoot , cmd , target ) ;
44
+ const outputBundleOptions = await build ( projectRoot , cmd , ... cmdArgs ) ;
35
45
await generateOutputDirectory ( root , outputBundleOptions ) ;
36
46
37
47
await validateOutputDirectory ( outputBundleOptions ) ;
0 commit comments