fix Conflicting

This commit is contained in:
ausir 2017-05-21 22:47:03 +08:00
commit 3f56457f79

View File

@ -46,7 +46,6 @@ export default async function () {
** Set variables
*/
this.options.generate = _.defaultsDeep(this.options.generate, defaults)
var self = this
var srcStaticPath = resolve(this.srcDir, 'static')
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
var distPath = resolve(this.dir, this.options.generate.dir)
@ -54,7 +53,7 @@ export default async function () {
/*
** Launch build process
*/
await self.build()
await this.build()
/*
** Clean destination folder
*/
@ -96,30 +95,32 @@ export default async function () {
while (routes.length) {
let n = 0
await Promise.all(routes.splice(0, 500).map(async (route) => {
await waitFor(n++ * self.options.generate.interval)
await waitFor(n++ * this.options.generate.interval)
let html
try {
var { html, error } = await self.renderRoute(route, { _generate: true })
if (error) {
errors.push({ type: 'handled', route, error })
const res = await this.renderRoute(route, { _generate: true })
html = res.html
if (res.error) {
errors.push({ type: 'handled', route, error: res.error })
}
} catch (err) {
/* istanbul ignore next */
errors.push({ type: 'unhandled', route, error: err })
}
if (self.options.generate.minify !== false) {
if (this.options.generate.minify !== false) {
try {
var minifiedHtml = minify(html, self.options.generate.minify)
html = minify(html, this.options.generate.minify)
} catch (err) /* istanbul ignore next */ {
let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`)
errors.push({ type: 'unhandled', route, error: minifyErr })
}
}
var path = join(route, sep, 'index.html') // /about -> /about/index.html
let path = join(route, sep, 'index.html') // /about -> /about/index.html
debug('Generate file: ' + path)
path = join(distPath, path)
// Make sure the sub folders are created
await mkdirp(dirname(path))
await writeFile(path, minifiedHtml || html, 'utf8')
await writeFile(path, html, 'utf8')
}))
}
// Add .nojekyll file to let Github Pages add the _nuxt/ folder