Skip to content

Commit

Permalink
chore: improved logs for events
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Dec 29, 2024
1 parent dc8bdb6 commit d8e1de6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/github/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,19 @@ function checkExpression(value: string, allIds: Set<string>, calledIds: Set<stri

async function download({ context, repository, owner }: { context: GitHubContext; repository: string; owner: string }): Promise<string | null> {
if (!repository || !owner) throw new Error("Repo or owner is not defined");
const filePath = context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH;
try {
const { data } = await context.octokit.rest.repos.getContent({
owner,
repo: repository,
path: context.eventHandler.environment === "production" ? CONFIG_FULL_PATH : DEV_CONFIG_FULL_PATH,
path: filePath,
mediaType: { format: "raw" },
});
return data as unknown as string; // this will be a string if media format is raw
} catch (err) {
// In case of a missing config, do not log is as an error
if (err && typeof err === "object" && "status" in err && err.status === 404) {
console.log(`No configuration file was found in the repository ${owner}/${repository}.`);
console.log(`No configuration file was found at ${owner}/${repository}/${filePath}.`);
} else {
console.error(err);
}
Expand Down

0 comments on commit d8e1de6

Please sign in to comment.