Skip to content

Commit

Permalink
0.4.4 1
Browse files Browse the repository at this point in the history
  • Loading branch information
seed-of-apricot committed Oct 15, 2020
1 parent b451253 commit fb3cbe5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
9 changes: 7 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

36 changes: 20 additions & 16 deletions src/getFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@ export const getFiles = async (
const path = globToRegex(core.getInput('flagPath'), { globstar: true });
const octokit = github.getOctokit(token);

const files = commits.flatMap(item =>
item.data.files.reduce((prev, file) => {
if (file.filename.match(path) !== null && file.status !== 'removed') {
return [
...prev,
octokit.repos.getContent({
...github.context.repo,
path: file.filename,
ref: item.data.sha,
}),
];
} else {
return prev;
}
}, [] as Promise<OctokitResponse<ReposGetContentResponseData>>[]),
);
const files = commits
.sort((a, b) =>
a.data.commit.author.date > b.data.commit.author.date ? -1 : 1,
)
.flatMap(item =>
item.data.files.reduce((prev, file) => {
if (file.filename.match(path) !== null && file.status !== 'removed') {
return [
...prev,
octokit.repos.getContent({
...github.context.repo,
path: file.filename,
ref: item.data.sha,
}),
];
} else {
return prev;
}
}, [] as Promise<OctokitResponse<ReposGetContentResponseData>>[]),
);
return Promise.all(files);
};
8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ const main = async (): Promise<void> => {

console.log('files have been retrieved');
const summaryData = convertFiles(await summary);
const filesData = (await files).map(item => convertFiles(item));
const filesData = (await files)
.filter(
(item, index, array) =>
array.map(element => element.data.path).indexOf(item.data.path) ===
index,
)
.map(item => convertFiles(item));
const newSummary = processFiles(summaryData, filesData);
console.log('new summary has been compiled');
writeNewSummary(await newSummary);
Expand Down

0 comments on commit fb3cbe5

Please sign in to comment.