Skip to content

Commit

Permalink
Refactor object key names in run function
Browse files Browse the repository at this point in the history
  • Loading branch information
austenstone committed Jan 31, 2024
1 parent 82dc3ce commit 9fe9ed3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,21 @@ export const run = async (): Promise<void> => {
}
const results = Object.fromEntries(await Promise.all(
await Object.entries(requests).map(async ([type, request]) => {
const response = await request;
return [type, response];
const data = await request;
return [type, data];
})
));
info('GitHub Security Alerts retrieved successfully');

if (input.createArtifact) {
startGroup('Creating GitHub Security Alerts artifact');
const artifact = new DefaultArtifactClient();
await Promise.all(Object.entries(results).map(async ([key, value]) => {
await Promise.all(Object.entries(results).map(async ([type, data]) => {
const fileName = `${type}.json`;
return new Promise<void>((resolve, reject) => {
writeFile(key, JSON.stringify(value, null, 2), (err) => err ? reject(err) : resolve());
writeFile(fileName, JSON.stringify(data, null, 2), (err) => err ? reject(err) : resolve());
}).then(() => {
return artifact.uploadArtifact(key, [key], '.', { compressionLevel: 0 });
return artifact.uploadArtifact(type, [fileName], '.', { compressionLevel: 0 });
});
}));
info('GitHub Security Alerts artifact created successfully');
Expand Down

0 comments on commit 9fe9ed3

Please sign in to comment.