utils.js
1 const sleep = require('await-sleep') 2 3 const isRunning = (pid) => { 4 try { 5 return process.kill(pid,0) 6 } catch (e) { 7 return e.code === 'EPERM' 8 } 9 } 10 11 const waitForProc = async (pid) => { 12 while (isRunning(pid)) { 13 await sleep(5000) 14 } 15 } 16 17 module.exports = { isRunning, waitForProc }