From 638b51c1581f724a10649b4e01199e546a72d1bd Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Wed, 2 Mar 2022 22:49:18 +0100 Subject: [PATCH] build: fix standalone release checks failing due to missing global `ReleaseAction` instance Fixes the standalone release checks running outside of the `.ng-dev` config load, which comes with the `global.ReleaseAction`. In standalone checks this variable is not defined and therefore currently causes errors like: ``` /.ng-dev/release.ts:14 const actionProto = (global as any).ReleaseAction.prototype; ^ TypeError: Cannot read properties of undefined (reading 'prototype') at Object. ``` We can fallback to the imported `ReleaseAction` constructor object if the global reference is not provided. In such cases the monkey-patching is a noop anyway. --- .ng-dev/release.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ng-dev/release.ts b/.ng-dev/release.ts index cd3993878860..a6ab85e7715a 100644 --- a/.ng-dev/release.ts +++ b/.ng-dev/release.ts @@ -1,6 +1,7 @@ import { BuiltPackage, ReleaseConfig, + ReleaseAction as _ReleaseAction, FatalReleaseActionError, } from '@angular/dev-infra-private/ng-dev'; import {SemVer} from 'semver'; @@ -11,7 +12,7 @@ import {join} from 'path'; // The `ng-dev` release tool exposes the `ReleaseAction` instance through `global`, // allowing it to be monkey-patched for our release checks. This can be removed // when the release tool has a public API for release checks. -const actionProto = (global as any).ReleaseAction.prototype; +const actionProto = ((global as any).ReleaseAction ?? _ReleaseAction).prototype; const _origStageFn = actionProto.stageVersionForBranchAndCreatePullRequest; const _origVerifyFn = actionProto._verifyPackageVersions;