From e1e3b405b4b3771899766748c95c9cc5ebec4f4b Mon Sep 17 00:00:00 2001 From: XadillaX Date: Fri, 10 Aug 2018 12:21:44 +0800 Subject: [PATCH 1/2] refactor: add `this.exit` to instead of `process.exit` --- lib/cmd/start.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cmd/start.js b/lib/cmd/start.js index c5e2188..0cf9a22 100644 --- a/lib/cmd/start.js +++ b/lib/cmd/start.js @@ -72,6 +72,10 @@ class StartCommand extends Command { return 'Start server at prod mode'; } + exit(code) { + process.exit(code); + } + * run(context) { const { argv, env, cwd, execArgv } = context; @@ -156,7 +160,7 @@ class StartCommand extends Command { this.logger.info('%s started on %s', this.frameworkName, msg.data.address); child.unref(); child.disconnect(); - process.exit(0); + this.exit(0); } }); @@ -177,7 +181,7 @@ class StartCommand extends Command { [ 'SIGINT', 'SIGQUIT', 'SIGTERM' ].forEach(event => { process.once(event, () => { signal = event; - process.exit(0); + this.exit(0); }); }); process.once('exit', () => { @@ -246,7 +250,7 @@ class StartCommand extends Command { if (!isSuccess) { this.child.kill('SIGTERM'); yield sleep(1000); - process.exit(1); + this.exit(1); } } } From a61e0a70e68171585a2a99460518d3fda55a8dcf Mon Sep 17 00:00:00 2001 From: XadillaX Date: Fri, 10 Aug 2018 12:40:35 +0800 Subject: [PATCH 2/2] f --- lib/cmd/start.js | 4 ---- lib/command.js | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/cmd/start.js b/lib/cmd/start.js index 0cf9a22..f55e060 100644 --- a/lib/cmd/start.js +++ b/lib/cmd/start.js @@ -72,10 +72,6 @@ class StartCommand extends Command { return 'Start server at prod mode'; } - exit(code) { - process.exit(code); - } - * run(context) { const { argv, env, cwd, execArgv } = context; diff --git a/lib/command.js b/lib/command.js index c484252..bd53436 100644 --- a/lib/command.js +++ b/lib/command.js @@ -59,6 +59,10 @@ class Command extends BaseCommand { return context; } + + exit(code) { + process.exit(code); + } } module.exports = Command;