From 89d5f3753ea292549bd89348bdc717ba40ede06e Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 1 Apr 2018 00:50:14 +0430 Subject: [PATCH] perf: prevent duplicate showReady --- bin/nuxt-dev | 2 +- bin/nuxt-start | 2 +- lib/builder/webpack/base.js | 2 +- lib/core/nuxt.js | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/nuxt-dev b/bin/nuxt-dev index 59ad0885dd..0e2c1ac672 100755 --- a/bin/nuxt-dev +++ b/bin/nuxt-dev @@ -129,7 +129,7 @@ function startDev(oldInstance) { // Pass new nuxt to watch chain .then(() => instance) // Call showReady - .then(() => nuxt.showReady(true)) + .then(() => nuxt.showReady()) // Handle errors .catch(err => onError(err, instance)) ) diff --git a/bin/nuxt-start b/bin/nuxt-start index 0c6b30035e..b948a190c2 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -81,5 +81,5 @@ if (nuxt.options.render.ssr === true) { const { port, host } = getLatestHost(argv) nuxt.listen(port, host).then(() => { - nuxt.showReady() + nuxt.showReady(false) }) diff --git a/lib/builder/webpack/base.js b/lib/builder/webpack/base.js index bcc116af67..2a5ce4315c 100644 --- a/lib/builder/webpack/base.js +++ b/lib/builder/webpack/base.js @@ -209,7 +209,7 @@ export default class WebpackBaseConfig { compiledIn: false, done: () => { if (this.options.dev) { - this.nuxt.showReady(true) + this.nuxt.showReady() } } })) diff --git a/lib/core/nuxt.js b/lib/core/nuxt.js index e0b4c1ab0e..3c3f71adc3 100644 --- a/lib/core/nuxt.js +++ b/lib/core/nuxt.js @@ -21,7 +21,7 @@ export default class Nuxt { constructor(options = {}) { this.options = Options.from(options) - this.readyMessage = 'Ready' + this.readyMessage = null this.initialized = false // Hooks @@ -106,7 +106,11 @@ export default class Nuxt { }) } - showReady(clear = false) { + showReady(clear = true) { + if (!this.readyMessage) { + return + } + logger.ready({ message: this.readyMessage, badge: true,