From 967ecf39739e4b21ca7b1f8b4c15ca5874b9e4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sun, 26 Sep 2021 13:53:59 +0800 Subject: [PATCH] build: fix MaxListenersExceededWarning (#3637) --- build/utils/process.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/utils/process.ts b/build/utils/process.ts index 4ed8459a85..504b2db309 100644 --- a/build/utils/process.ts +++ b/build/utils/process.ts @@ -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) })