mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
refactor: change settimeout to waitFor (#2220)
This commit is contained in:
parent
65f4a030f4
commit
30714c989a
@ -9,7 +9,7 @@ import { join, resolve, basename, extname, dirname } from 'path'
|
||||
import MFS from 'memory-fs'
|
||||
import webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import webpackHotMiddleware from 'webpack-hot-middleware'
|
||||
import { r, wp, wChunk, createRoutes, sequence, relativeTo, isPureObject } from 'utils'
|
||||
import { r, wp, wChunk, createRoutes, sequence, relativeTo, isPureObject, waitFor } from 'utils'
|
||||
import Debug from 'debug'
|
||||
import Glob from 'glob'
|
||||
import clientWebpackConfig from './webpack/client.config.js'
|
||||
@ -132,11 +132,8 @@ export default class Builder {
|
||||
// If building
|
||||
/* istanbul ignore if */
|
||||
if (this._buildStatus === STATUS.BUILDING) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(this.build())
|
||||
}, 1000)
|
||||
})
|
||||
await waitFor(1000)
|
||||
return this.build()
|
||||
}
|
||||
this._buildStatus = STATUS.BUILDING
|
||||
|
||||
|
@ -23,9 +23,7 @@ export function setAnsiColors(ansiHTML) {
|
||||
}
|
||||
|
||||
export async function waitFor(ms) {
|
||||
return new Promise(function (resolve) {
|
||||
setTimeout(resolve, (ms || 0))
|
||||
})
|
||||
return new Promise(resolve => setTimeout(resolve, (ms || 0)))
|
||||
}
|
||||
|
||||
export function urlJoin() {
|
||||
|
@ -8,7 +8,7 @@ import _ from 'lodash'
|
||||
import { join, resolve } from 'path'
|
||||
import fs from 'fs-extra'
|
||||
import { createBundleRenderer } from 'vue-server-renderer'
|
||||
import { getContext, setAnsiColors, isUrl } from 'utils'
|
||||
import { getContext, setAnsiColors, isUrl, waitFor } from 'utils'
|
||||
import Debug from 'debug'
|
||||
import Youch from '@nuxtjs/youch'
|
||||
import { SourceMapConsumer } from 'source-map'
|
||||
@ -472,9 +472,8 @@ export default class Renderer {
|
||||
async renderRoute(url, context = {}) {
|
||||
/* istanbul ignore if */
|
||||
if (!this.isReady) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => resolve(this.renderRoute(url, context)), 1000)
|
||||
})
|
||||
await waitFor(1000)
|
||||
return this.renderRoute(url, context)
|
||||
}
|
||||
|
||||
// Log rendered url
|
||||
|
Loading…
Reference in New Issue
Block a user