From fdf2e02bff80c4a75cb7d64d3b920dbbbaeb746f Mon Sep 17 00:00:00 2001 From: Zach Arend Date: Tue, 4 May 2021 16:25:39 -0700 Subject: [PATCH] build: fix crash when validating commit messages (#41949) Fixes a crash when running the `ValidateFileModule`. PR Close #41949 --- dev-infra/commit-message/validate-file/cli.ts | 5 ++++- dev-infra/ng-dev.js | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dev-infra/commit-message/validate-file/cli.ts b/dev-infra/commit-message/validate-file/cli.ts index 82f9800c3e93e..8ba2d5b2856b3 100644 --- a/dev-infra/commit-message/validate-file/cli.ts +++ b/dev-infra/commit-message/validate-file/cli.ts @@ -31,7 +31,10 @@ function builder(yargs: Argv) { type: 'string', conflicts: ['file'], description: 'The key of the environment variable for the path of the commit message file.', - coerce: (arg: string) => { + coerce: (arg: string|undefined) => { + if (arg === undefined) { + return arg; + } const file = process.env[arg]; if (!file) { throw new Error(`Provided environment variable "${arg}" was not found.`); diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index 3975357740ec8..fdaa7c2df60a5 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -2113,6 +2113,9 @@ function builder$2(yargs) { conflicts: ['file'], description: 'The key of the environment variable for the path of the commit message file.', coerce: (arg) => { + if (arg === undefined) { + return arg; + } const file = process.env[arg]; if (!file) { throw new Error(`Provided environment variable "${arg}" was not found.`);