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
This commit is contained in:
Joey Perrott
2021-04-13 11:22:07 -07:00
committed by Zach Arend
parent c9aa87cec0
commit 15c307b200
2 changed files with 11 additions and 2 deletions
+6 -1
View File
@@ -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;
},
})
+5 -1
View File
@@ -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;
},
})