perf: prevent duplicate showReady

This commit is contained in:
Pooya Parsa 2018-04-01 00:50:14 +04:30
parent a5373f2464
commit 89d5f3753e
4 changed files with 9 additions and 5 deletions

View File

@ -129,7 +129,7 @@ function startDev(oldInstance) {
// Pass new nuxt to watch chain // Pass new nuxt to watch chain
.then(() => instance) .then(() => instance)
// Call showReady // Call showReady
.then(() => nuxt.showReady(true)) .then(() => nuxt.showReady())
// Handle errors // Handle errors
.catch(err => onError(err, instance)) .catch(err => onError(err, instance))
) )

View File

@ -81,5 +81,5 @@ if (nuxt.options.render.ssr === true) {
const { port, host } = getLatestHost(argv) const { port, host } = getLatestHost(argv)
nuxt.listen(port, host).then(() => { nuxt.listen(port, host).then(() => {
nuxt.showReady() nuxt.showReady(false)
}) })

View File

@ -209,7 +209,7 @@ export default class WebpackBaseConfig {
compiledIn: false, compiledIn: false,
done: () => { done: () => {
if (this.options.dev) { if (this.options.dev) {
this.nuxt.showReady(true) this.nuxt.showReady()
} }
} }
})) }))

View File

@ -21,7 +21,7 @@ export default class Nuxt {
constructor(options = {}) { constructor(options = {}) {
this.options = Options.from(options) this.options = Options.from(options)
this.readyMessage = 'Ready' this.readyMessage = null
this.initialized = false this.initialized = false
// Hooks // Hooks
@ -106,7 +106,11 @@ export default class Nuxt {
}) })
} }
showReady(clear = false) { showReady(clear = true) {
if (!this.readyMessage) {
return
}
logger.ready({ logger.ready({
message: this.readyMessage, message: this.readyMessage,
badge: true, badge: true,