From d739cebeb7208bd20342db8063a6db1979f1895c Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Fri, 24 Sep 2021 20:46:51 +0300 Subject: [PATCH] refactor: code --- lib/Server.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index afcb4304bf..44584dd3c7 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -1116,11 +1116,15 @@ class Server { let needForceShutdown = false; + const exitProcess = () => { + // eslint-disable-next-line no-process-exit + process.exit(); + }; + signals.forEach((signal) => { process.on(signal, () => { if (needForceShutdown) { - // eslint-disable-next-line no-process-exit - process.exit(); + exitProcess(); } this.logger.info( @@ -1130,14 +1134,10 @@ class Server { needForceShutdown = true; this.stopCallback(() => { - if (this.compiler.close) { - this.compiler.close(() => { - // eslint-disable-next-line no-process-exit - process.exit(); - }); + if (typeof this.compiler.close === "function") { + this.compiler.close(exitProcess); } else { - // eslint-disable-next-line no-process-exit - process.exit(); + exitProcess(); } }); });