build: fix MaxListenersExceededWarning (#3637)

This commit is contained in:
三咲智子
2021-09-26 13:53:59 +08:00
committed by GitHub
parent 51cc956589
commit 967ecf3973

View File

@@ -12,12 +12,17 @@ export const run = async (command: string, cwd: string = projRoot) =>
cwd,
stdio: 'inherit',
})
const onProcessExit = () => app.kill('SIGHUP')
app.on('close', (code) => {
process.removeListener('exit', onProcessExit)
if (code === 0) resolve()
else
reject(
new Error(`Command failed. \n Command: ${command} \n Code: ${code}`)
)
})
process.on('exit', () => app.kill('SIGHUP'))
process.on('exit', onProcessExit)
})