Skip to content

Commit 9b4accf

Browse files
committed
Merge branch 'main' into fix-excludedPath
2 parents 0de48cc + e6fab5f commit 9b4accf

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"eslint-plugin-unicorn": "^49.0.0",
5858
"husky": "^4.3.0",
5959
"netlify-cli": "^17.2.0",
60+
"npm-run-all": "^4.1.5",
6061
"prettier": "^2.1.2"
6162
},
6263
"dependencies": {

src/helpers/setUpEdgeFunction.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const { Buffer } = require('node:buffer')
22
const { existsSync, readdirSync } = require('node:fs')
33
const { writeFile, mkdir, readFile } = require('node:fs/promises')
44
const { join, relative, sep, posix } = require('node:path')
5+
const process = require('node:process')
56

67
const { readJson } = require('fs-extra')
78

@@ -20,8 +21,26 @@ const getAllFilesIn = (dir) =>
2021

2122
const toPosix = (path) => path.split(sep).join(posix.sep)
2223

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+
2544
return angularJson.projects[projectName]
2645
}
2746

@@ -62,7 +81,6 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild }) => {
6281
import process from "node:process"
6382
6483
globalThis.process = process
65-
globalThis.global = globalThis
6684
globalThis.DenoEvent = globalThis.Event // storing this for fixup-event.mjs
6785
`
6886

0 commit comments

Comments
 (0)