Skip to content

Commit

Permalink
fix: messy promises, TODO - more err handling cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
olivercodes committed Aug 11, 2022
1 parent d03014a commit e60bc2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const {Octokit} = __nccwpck_require__(1231)
const core = __nccwpck_require__(2186);
const octokit = new Octokit();

function uniq(a) {
Expand Down Expand Up @@ -34,14 +35,17 @@ async function getRepoTeams(org, repo) {
return Promise.resolve(data
.filter(team => teamHasWrite(team.permission))
.map(team => team.name)
);
).catch(err => { core.setFailed(err) });
}

async function getUserIsApprover(org, repo, user) {
const repoTeams = await getRepoTeams(org, repo);
teamsArrays = await Promise.all(
repoTeams.map(team => getTeamUsers(team))
);
).catch((err) => {
console.error(err)
core.setFailed(err);
});

const allApprovingUsers = teamsArrays
.reduce((acc, arr) => acc.concat(arr));
Expand Down
8 changes: 6 additions & 2 deletions lib/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const {Octokit} = require('@octokit/action')
const core = require('@actions/core');
const octokit = new Octokit();

function uniq(a) {
Expand Down Expand Up @@ -28,14 +29,17 @@ async function getRepoTeams(org, repo) {
return Promise.resolve(data
.filter(team => teamHasWrite(team.permission))
.map(team => team.name)
);
).catch(err => { core.setFailed(err) });
}

async function getUserIsApprover(org, repo, user) {
const repoTeams = await getRepoTeams(org, repo);
teamsArrays = await Promise.all(
repoTeams.map(team => getTeamUsers(team))
);
).catch((err) => {
console.error(err)
core.setFailed(err);
});

const allApprovingUsers = teamsArrays
.reduce((acc, arr) => acc.concat(arr));
Expand Down

0 comments on commit e60bc2e

Please sign in to comment.