Pass a logger in to getApiClient() rather than constructing one there.

This commit is contained in:
Chris Gavin 2020-11-02 08:53:25 +00:00
parent 1f7bae7ab8
commit 865b4bd832
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
12 changed files with 29 additions and 27 deletions

8
lib/config-utils.js generated
View file

@ -304,7 +304,7 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
async function getLanguagesInRepo(repository, githubAuth, githubUrl, mode, logger) {
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
const response = await api
.getApiClient(githubAuth, githubUrl, mode, true)
.getApiClient(githubAuth, githubUrl, mode, logger, true)
.repos.listLanguages({
owner: repository.owner,
repo: repository.repo,
@ -418,7 +418,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
parsedYAML = getLocalConfig(configFile, checkoutPath);
}
else {
parsedYAML = await getRemoteConfig(configFile, githubAuth, githubUrl, mode);
parsedYAML = await getRemoteConfig(configFile, githubAuth, githubUrl, mode, logger);
}
// Validate that the 'name' property is syntactically correct,
// even though we don't use the value yet.
@ -546,7 +546,7 @@ function getLocalConfig(configFile, checkoutPath) {
}
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
}
async function getRemoteConfig(configFile, githubAuth, githubUrl, mode) {
async function getRemoteConfig(configFile, githubAuth, githubUrl, mode, logger) {
// retrieve the various parts of the config location, and ensure they're present
const format = new RegExp("(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)");
const pieces = format.exec(configFile);
@ -555,7 +555,7 @@ async function getRemoteConfig(configFile, githubAuth, githubUrl, mode) {
throw new Error(getConfigFileRepoFormatInvalidMessage(configFile));
}
const response = await api
.getApiClient(githubAuth, githubUrl, mode, true)
.getApiClient(githubAuth, githubUrl, mode, logger, true)
.repos.getContent({
owner: pieces.groups.owner,
repo: pieces.groups.repo,