Format code

This commit is contained in:
Sebastien Chopin 2017-05-05 12:11:32 +02:00
parent 71c9838008
commit fd833216df
2 changed files with 15 additions and 17 deletions

View File

@ -32,9 +32,7 @@ const defaultTransition = <%=
.replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(')
%>
export { NuxtError }
export function createApp (ssrContext) {
function createApp (ssrContext) {
<% if (store) { %>
const store = createStore()
<% } %>
@ -119,3 +117,5 @@ export function createApp (ssrContext) {
return { app, router<%= (store ? ', store' : '') %> }
}
export { createApp, NuxtError }

View File

@ -101,18 +101,17 @@ export default function () {
try {
var { html, error } = yield self.renderRoute(route, { _generate: true })
if(error) {
errors.push({type : "handled", route, error})
errors.push({ type : 'handled', route, error })
}
} catch(err) {
errors.push({type : "unhandled", route, error : err})
} catch (err) {
errors.push({ type : 'unhandled', route, error: err })
return
}
try {
var minifiedHtml = minify(html, self.options.generate.minify)
} catch(err) {
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})
errors.push({ type : 'unhandled', route, error: minifyErr })
return
}
var path = join(route, sep, 'index.html') // /about -> /about/index.html
@ -136,15 +135,14 @@ export default function () {
const duration = Math.round((Date.now() - s) / 100) / 10
debug(`HTML Files generated in ${duration}s`)
if(errors.length) {
console.error("==== Error report ==== \n" + errors.map( ({type, route, error}) => {
if(type == "unhandled") {
return `Route: '${route}'\n${error.stack}`
} else {
return `Route: '${route}' returned an error via context.error: \n` +
JSON.stringify(error)
}
}).join("\n\n"))
if (errors.length) {
console.error('==== Error report ==== \n' + errors.map( ({type, route, error}) => {
if(type === 'unhandled') {
return `Route: '${route}'\n${error.stack}`
} else {
return `Route: '${route}' thrown an error: \n` + JSON.stringify(error)
}
}).join('\n\n'))
}
return this
})