Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: wait for process to be killed before tmp dir gets wiped
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Jun 5, 2019
1 parent 8dbb73b commit 86bce41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
12 changes: 9 additions & 3 deletions features/support/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fs = require('fs-extra');
const net = require('net');
const url = require('url');
const which = require('which');
const kill = require('tree-kill');
const pidtree = require('pidtree');
const {
Given,
When,
Expand All @@ -25,8 +25,14 @@ Before(function hook() {
});

After(async function hook() {
fs.remove(this.dir);
await util.promisify(kill)(this.proc.pid);
const pids = [];
try {
pids.push(...await pidtree(this.proc.pid));
} catch (error) {
// the process doesn't exist anymore
}
pids.forEach(pid => process.kill(pid, 'SIGKILL'));
return fs.remove(this.dir);
});


Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dredd": "11.2.6",
"fs-extra": "8.0.1",
"glob": "7.1.4",
"tree-kill": "1.2.1",
"pidtree": "0.3.0",
"which": "1.3.1"
},
"devDependencies": {
Expand Down

0 comments on commit 86bce41

Please sign in to comment.