Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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()
})
}))
.map(async ({ route, payload }) => {
await waitFor(n++ * this.options.generate.interval)
await this.generateRoute({ route, payload, errors })
})
)