update generate cli & tests

This commit is contained in:
Pooya Parsa 2018-01-11 20:03:30 +03:30
parent 13166bcf78
commit 061059beb4
3 changed files with 15 additions and 10 deletions

View File

@ -112,7 +112,7 @@ if (options.mode !== 'spa') {
return `Route: '${route}' thrown an error: \n` + JSON.stringify(error)
}
})
Utils.printError(report.join('\n\n'), 'Generate errors')
Utils.printError(report.join('\n\n'), 'Generate errors summary:')
}
})

View File

@ -96,7 +96,7 @@ nuxt.hook('generate:done', (generator, errors) => {
return `Route: '${route}' thrown an error: \n` + JSON.stringify(error)
}
})
Utils.printError(report.join('\n\n'), 'generate')
Utils.printError(report.join('\n\n'), 'Generate errors summary:')
}
})

View File

@ -9,7 +9,7 @@ const execify = promisify(exec)
const rootDir = resolve(__dirname, 'fixtures/basic')
const port = 4011
const url = (route) => 'http://localhost:' + port + route
const url = route => 'http://localhost:' + port + route
test.serial('bin/nuxt-build', async t => {
const binBuild = resolve(__dirname, '..', 'bin', 'nuxt-build')
@ -33,19 +33,19 @@ test.serial('bin/nuxt-start', async t => {
const nuxtStart = spawn('node', [binStart, rootDir], { env: env })
nuxtStart.stdout.on('data', (data) => {
nuxtStart.stdout.on('data', data => {
stdout += data
})
nuxtStart.stderr.on('data', (data) => {
nuxtStart.stderr.on('data', data => {
stderr += data
})
nuxtStart.on('error', (err) => {
nuxtStart.on('error', err => {
error = err
})
nuxtStart.on('close', (code) => {
nuxtStart.on('close', code => {
exitCode = code
})
@ -66,13 +66,18 @@ test.serial('bin/nuxt-start', async t => {
// Wait max 10s for the process to be killed
iterator = 0
while (exitCode === undefined && iterator < 40) { // eslint-disable-line no-unmodified-loop-condition
while (exitCode === undefined && iterator < 40) {
// eslint-disable-line no-unmodified-loop-condition
await Utils.waitFor(250)
iterator++
}
if (iterator >= 40) {
t.log(`WARN: we were unable to automatically kill the child process with pid: ${nuxtStart.pid}`)
t.log(
`WARN: we were unable to automatically kill the child process with pid: ${
nuxtStart.pid
}`
)
}
t.is(stderr, '')
@ -88,6 +93,6 @@ test.serial('bin/nuxt-generate', async t => {
t.true(stderr.includes('Destination folder cleaned'))
t.true(stderr.includes('Static & build files copied'))
t.true(stderr.includes(`Generate file: ${sep}users${sep}1${sep}index.html`))
t.true(stderr.includes('Error report'))
t.true(stderr.includes('Generate errors summary:'))
t.true(stderr.includes('Generate done'))
})