From 15c307b2008bd4c299245bfc28b5d3a23b020fd0 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Tue, 13 Apr 2021 11:22:07 -0700 Subject: [PATCH] fix(dev-infra): only create authenticated github instance once in yargs (#41603) Fix github token option for yargs to only create an authenticated token one time. PR Close #41603 --- dev-infra/ng-dev.js | 7 ++++++- dev-infra/utils/git/github-yargs.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index a66620f986..d5214b1940 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -805,7 +805,12 @@ function addGithubTokenOption(yargs) { error(yellow("You can generate a token here: " + GITHUB_TOKEN_GENERATE_URL)); process.exit(1); } - GitClient.authenticateWithToken(githubToken); + try { + GitClient.getAuthenticatedInstance(); + } + catch (_a) { + GitClient.authenticateWithToken(githubToken); + } return githubToken; }, }) diff --git a/dev-infra/utils/git/github-yargs.ts b/dev-infra/utils/git/github-yargs.ts index e695bafd0a..751d35f5db 100644 --- a/dev-infra/utils/git/github-yargs.ts +++ b/dev-infra/utils/git/github-yargs.ts @@ -32,7 +32,11 @@ export function addGithubTokenOption(yargs: Argv): ArgvWithGithubToken { error(yellow(`You can generate a token here: ${GITHUB_TOKEN_GENERATE_URL}`)); process.exit(1); } - GitClient.authenticateWithToken(githubToken); + try { + GitClient.getAuthenticatedInstance(); + } catch { + GitClient.authenticateWithToken(githubToken); + } return githubToken; }, })