From 547e4f98a7cfc56eadc900d5266ee096a7a88703 Mon Sep 17 00:00:00 2001 From: ULIVZ <472590061@qq.com> Date: Mon, 11 Mar 2019 01:40:53 +0800 Subject: [PATCH] feat($core): optional callback when socket connection is ready under dev. --- packages/@vuepress/core/lib/node/App.js | 4 ++-- packages/@vuepress/core/lib/node/dev/index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/core/lib/node/App.js b/packages/@vuepress/core/lib/node/App.js index 4b1ab57f28..bae5b61557 100755 --- a/packages/@vuepress/core/lib/node/App.js +++ b/packages/@vuepress/core/lib/node/App.js @@ -451,7 +451,7 @@ module.exports = class App { * @api public */ - async dev () { + async dev (callback) { this.isProd = false this.devProcess = new DevProcess(this) await this.devProcess.process() @@ -462,7 +462,7 @@ module.exports = class App { this.process() }) .createServer() - .listen() + .listen(callback) } /** diff --git a/packages/@vuepress/core/lib/node/dev/index.js b/packages/@vuepress/core/lib/node/dev/index.js index 4267b3bfc0..9f2cf2703c 100644 --- a/packages/@vuepress/core/lib/node/dev/index.js +++ b/packages/@vuepress/core/lib/node/dev/index.js @@ -250,7 +250,7 @@ module.exports = class DevProcess extends EventEmitter { listen (callback) { this.server.listen(this.port, this.host, (err) => { - if (callback) { + if (typeof callback === 'function') { callback(err) } })