Skip to content

Commit

Permalink
cp
Browse files Browse the repository at this point in the history
  • Loading branch information
slavingia committed Sep 25, 2024
1 parent 1cb49fb commit 0833ab1
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,27 +289,37 @@ export async function getPullRequestInfo(

while (queue.length > 0) {
const item = queue.shift();
if (item.type === "dir") {
if (item && item.type === "dir") {
const dirContents = await octokit.rest.repos.getContent({
owner,
repo,
path: item.path,
});
queue.push(...(dirContents.data as { path: string; type: string }[]));
} else if (
item &&
item.type === "file" &&
item.path.toLowerCase().includes(".test.")
) {
const fileContent = await octokit.rest.repos.getContent({
owner,
repo,
path: item.path,
mediaType: { format: "raw" },
});
testFiles.push({
name: item.path,
content: fileContent.data as string,
});

if (
"content" in fileContent.data &&
typeof fileContent.data.content === "string"
) {
const decodedContent = Buffer.from(
fileContent.data.content,
"base64"
).toString("utf-8");
testFiles.push({
name: item.path,
content: decodedContent,
});
}
}
}

Expand Down

0 comments on commit 0833ab1

Please sign in to comment.