Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(generator): option to merge generate output log into single line #5517

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/config/src/config/_common.js
Expand Up @@ -60,7 +60,8 @@ export default () => ({
concurrency: 500,
interval: 0,
subFolders: true,
fallback: '200.html'
fallback: '200.html',
mergeOutputLog: false
},

// Watch
Expand Down
Expand Up @@ -169,6 +169,7 @@ Object {
"interval": 0,
"routes": Array [],
"subFolders": true,
"mergeOutputLog": false,
},
"globalName": "nuxt",
"globals": Object {
Expand Down
12 changes: 10 additions & 2 deletions packages/generator/src/generator.js
Expand Up @@ -96,6 +96,7 @@ export default class Generator {

async generateRoutes(routes) {
const errors = []
let generatedRoutesCount = 0

// Start generate process
while (routes.length) {
Expand All @@ -105,11 +106,18 @@ export default class Generator {
.splice(0, this.options.generate.concurrency)
.map(async ({ route, payload }) => {
await waitFor(n++ * this.options.generate.interval)
await this.generateRoute({ route, payload, errors })
const routeGenerated = await this.generateRoute({ route, payload, errors })
if (routeGenerated) {
generatedRoutesCount++
}
})
)
}

if (this.options.generate.mergeOutputLog) {
consola.success('Generated ' + generatedRoutesCount + ' pages')
}

// Improve string representation for errors
// TODO: Use consola for more consistency
errors.toString = () => this._formatErrors(errors)
Expand Down Expand Up @@ -265,7 +273,7 @@ export default class Generator {
if (pageErrors.length) {
consola.error('Error generating ' + route)
errors.push(...pageErrors)
} else {
} else if (!this.options.generate.mergeOutputLog) {
consola.success('Generated ' + route)
}

Expand Down