How to use the @nuxt/utils.waitFor function in @nuxt/utils

To help you get started, we’ve selected a few @nuxt/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nuxt / nuxt.js / packages / builder / src / builder.js View on Github external
async build () {
    // Avoid calling build() method multiple times when dev:true
    if (this._buildStatus === STATUS.BUILD_DONE && this.options.dev) {
      return this
    }
    // If building
    if (this._buildStatus === STATUS.BUILDING) {
      await waitFor(1000)
      return this.build()
    }
    this._buildStatus = STATUS.BUILDING

    if (this.options.dev) {
      consola.info('Preparing project for development')
      consola.info('Initial build may take a while')
    } else {
      consola.info('Production build')
    }

    // Wait for nuxt ready
    await this.nuxt.ready()

    // Call before hook
    await this.nuxt.callHook('build:before', this, this.options.build)
github nuxt / press / src / pool.js View on Github external
return new Promise(async (resolve) => {
        while (this.jobs.length) {
          let job
          try {
            job = this.jobs.pop()
            await this.handler(job.payload)
          } catch (err) {
            if (job.retries && job.retries === maxRetries) {
              consola.warn('Job exceeded retry limit: ', job)
              break
            }

            if (maxRetries > 0) {
              job.retries = job.retries ? job.retries + 1 : 1

              await waitFor(failureInterval)
              this.jobs.unshift(job)

              consola.warn('Requeued job due to failure: ', job, err)
              break
            }

            consola.warn('Job failed: ', job, err)
          }
        }
        resolve()
      })
    }))
github nuxt / nuxt.js / packages / generator / src / generator.js View on Github external
.map(async ({ route, payload }) => {
            await waitFor(n++ * this.options.generate.interval)
            await this.generateRoute({ route, payload, errors })
          })
      )