Skip to content

Commit

Permalink
Hopefully fix process exiting too early
Browse files Browse the repository at this point in the history
  • Loading branch information
lots0logs committed Jun 5, 2020
1 parent 4367317 commit f1fbe31
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ function isRenamed(file) {
return 'renamed' === file.status;
}

function outputResults() {
async function outputResults() {
debug('FILES', Array.from(FILES.values()));

core.setOutput('all', toJSON(Array.from(FILES.values()), 0));
Expand All @@ -387,7 +387,7 @@ function outputResults() {
fs.writeFileSync(`${process.env.HOME}/files_deleted.json`, toJSON(Array.from(FILES_REMOVED.values()), 0), 'utf-8');
}

function processCommitData(result) {
async function processCommitData(result) {
debug('Processing API Response', result);

if (! result || ! result.data) {
Expand Down Expand Up @@ -444,9 +444,10 @@ getCommits().then(commits => {
}

Promise.all(commits.map(fetchCommitData))
.then(data => data.map(processCommitData))
.then(data => Promise.all(data.map(processCommitData)))
.then(outputResults)
.then(() => process.exit(0));
.then(() => process.exit(0))
.catch(err => core.error(err) && process.exit(1));
});


Expand Down
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function isRenamed(file) {
return 'renamed' === file.status;
}

function outputResults() {
async function outputResults() {
debug('FILES', Array.from(FILES.values()));

core.setOutput('all', toJSON(Array.from(FILES.values()), 0));
Expand All @@ -99,7 +99,7 @@ function outputResults() {
fs.writeFileSync(`${process.env.HOME}/files_deleted.json`, toJSON(Array.from(FILES_REMOVED.values()), 0), 'utf-8');
}

function processCommitData(result) {
async function processCommitData(result) {
debug('Processing API Response', result);

if (! result || ! result.data) {
Expand Down Expand Up @@ -156,8 +156,9 @@ getCommits().then(commits => {
}

Promise.all(commits.map(fetchCommitData))
.then(data => data.map(processCommitData))
.then(data => Promise.all(data.map(processCommitData)))
.then(outputResults)
.then(() => process.exit(0));
.then(() => process.exit(0))
.catch(err => core.error(err) && process.exit(1));
});

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gh-action-get-changed-files",
"version": "2.1.1rc3",
"version": "2.1.1rc4",
"private": true,
"main": "dist/index.js",
"scripts":{
Expand Down

0 comments on commit f1fbe31

Please sign in to comment.