Skip to content

Commit

Permalink
Small refactoring on cleanup option
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 30, 2019
1 parent e5ed8de commit 739f683
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ const execa = (file, args, options) => {
return promise;
})();

const processDone = new Promise(resolve => {
const processDone = pFinally(new Promise(resolve => {
spawned.on('exit', (code, signal) => {
cleanup();

if (timedOut) {
resolvable.resolve([
{code, signal}, '', '', ''
Expand All @@ -281,17 +279,15 @@ const execa = (file, args, options) => {
});

spawned.on('error', error => {
cleanup();
resolve({error});
});

if (spawned.stdin) {
spawned.stdin.on('error', error => {
cleanup();
resolve({error});
});
}
});
}), cleanup);

function destroy() {
if (spawned.stdout) {
Expand Down

0 comments on commit 739f683

Please sign in to comment.