@@ -2,6 +2,7 @@ const { Buffer } = require('node:buffer')
2
2
const { existsSync, readdirSync } = require ( 'node:fs' )
3
3
const { writeFile, mkdir, readFile } = require ( 'node:fs/promises' )
4
4
const { join, relative, sep, posix } = require ( 'node:path' )
5
+ const process = require ( 'node:process' )
5
6
6
7
const { readJson } = require ( 'fs-extra' )
7
8
@@ -20,8 +21,26 @@ const getAllFilesIn = (dir) =>
20
21
21
22
const toPosix = ( path ) => path . split ( sep ) . join ( posix . sep )
22
23
23
- const getProject = ( angularJson ) => {
24
- const projectName = angularJson . defaultProject ?? Object . keys ( angularJson . projects ) [ 0 ]
24
+ const getProject = ( angularJson , failBuild ) => {
25
+ const selectedProject = process . env . ANGULAR_PROJECT
26
+ if ( selectedProject ) {
27
+ const project = angularJson . projects [ selectedProject ]
28
+ if ( ! project ) {
29
+ return failBuild (
30
+ `Could not find project selected project "${ selectedProject } " in angular.json. Please update the ANGULAR_PROJECT environment variable.` ,
31
+ )
32
+ }
33
+ return project
34
+ }
35
+
36
+ const projectNames = Object . keys ( angularJson . projects )
37
+ const [ projectName ] = projectNames
38
+ if ( projectNames . length > 1 ) {
39
+ console . warn (
40
+ `Found multiple projects in angular.json, deploying "${ projectName } ". To deploy a different one, set the ANGULAR_PROJECT environment variable to the project name.` ,
41
+ )
42
+ }
43
+
25
44
return angularJson . projects [ projectName ]
26
45
}
27
46
@@ -62,7 +81,6 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild }) => {
62
81
import process from "node:process"
63
82
64
83
globalThis.process = process
65
- globalThis.global = globalThis
66
84
globalThis.DenoEvent = globalThis.Event // storing this for fixup-event.mjs
67
85
`
68
86
0 commit comments