Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
chore: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
holazz committed May 16, 2022
1 parent c2476ce commit 825fa91
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,20 @@ async function getDefaultBranch(ctx: Context): Promise<string> {
}

async function fetchFiles(ctx: Context) {
const branch = ctx.branch || await getDefaultBranch(ctx)
const { data } = await ctx.octokit.rest.git.getTree({
owner: ctx.owner,
repo: ctx.repo,
tree_sha: branch,
const { octokit, owner, repo, path, branch } = ctx
const ref = branch || await getDefaultBranch(ctx)
const { data } = await octokit.rest.git.getTree({
owner,
repo,
tree_sha: ref,
recursive: '1',
})
const requests = data.tree
.filter(node => node.path?.startsWith(ctx.path || '') && node.type === 'blob')
.filter(node => node.path?.startsWith(path || '') && node.type === 'blob')
.map(async (node) => {
const { data: blob } = await ctx.octokit.git.getBlob({
owner: ctx.owner,
repo: ctx.repo,
owner,
repo,
file_sha: node.sha!,
})
return {
Expand Down

0 comments on commit 825fa91

Please sign in to comment.