This repository was archived by the owner on Nov 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const fs = require('fs-extra');
77const net = require ( 'net' ) ;
88const url = require ( 'url' ) ;
99const which = require ( 'which' ) ;
10- const kill = require ( 'tree-kill ' ) ;
10+ const pidtree = require ( 'pidtree ' ) ;
1111const {
1212 Given,
1313 When,
@@ -25,8 +25,24 @@ Before(function hook() {
2525} ) ;
2626
2727After ( async function hook ( ) {
28- fs . remove ( this . dir ) ;
29- await util . promisify ( kill ) ( this . proc . pid ) ;
28+ // kill all running processes
29+ const pids = [ ] ;
30+ try {
31+ pids . push ( ...await pidtree ( this . proc . pid ) ) ;
32+ } catch ( error ) {
33+ // the process doesn't exist anymore
34+ }
35+ pids . forEach ( ( pid ) => {
36+ try {
37+ process . kill ( pid , 'SIGKILL' ) ;
38+ } catch ( error ) {
39+ // re-throw except in case it is 'ESRCH' (process cannot be found)
40+ if ( error . code !== 'ESRCH' ) throw error ;
41+ }
42+ } ) ;
43+
44+ // remove the temporary directory
45+ return fs . remove ( this . dir ) ;
3046} ) ;
3147
3248
Original file line number Diff line number Diff line change 1414 "dredd" : " 11.2.6" ,
1515 "fs-extra" : " 8.0.1" ,
1616 "glob" : " 7.1.4" ,
17- "tree-kill " : " 1.2.1 " ,
17+ "pidtree " : " 0.3.0 " ,
1818 "which" : " 1.3.1"
1919 },
2020 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments