2018-03-18 20:11:43 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
process.env.NODE_ENV = 'test'
|
|
|
|
|
2018-03-19 00:51:06 +00:00
|
|
|
const { resolve } = require('path')
|
|
|
|
const { cpus } = require('os')
|
|
|
|
|
2018-03-23 08:54:11 +00:00
|
|
|
const execa = require('execa')
|
2018-03-19 05:17:48 +00:00
|
|
|
const Listr = require('listr')
|
2018-03-21 01:44:50 +00:00
|
|
|
const isCI = require('is-ci')
|
2018-03-18 20:11:43 +00:00
|
|
|
|
|
|
|
const fixtures = [
|
|
|
|
'children',
|
|
|
|
'custom-dirs',
|
|
|
|
'debug',
|
|
|
|
'deprecate',
|
|
|
|
'dynamic-routes',
|
|
|
|
'empty',
|
|
|
|
'error',
|
|
|
|
'module',
|
|
|
|
'ssr',
|
2018-03-19 00:51:06 +00:00
|
|
|
'with-config',
|
|
|
|
|
|
|
|
// csr,
|
|
|
|
// dev,
|
|
|
|
// generate,
|
|
|
|
// fail generate,
|
|
|
|
// fallback generate,
|
|
|
|
// ssr,
|
|
|
|
// ssr csp,
|
|
|
|
// spa
|
|
|
|
'basic'
|
2018-03-18 20:11:43 +00:00
|
|
|
]
|
|
|
|
|
2018-03-19 00:51:06 +00:00
|
|
|
const nuxtBuild = resolve(__dirname, '../bin/nuxt-build')
|
2018-03-18 20:11:43 +00:00
|
|
|
|
2018-03-19 05:17:48 +00:00
|
|
|
function buildFixture(name) {
|
2018-03-19 00:51:06 +00:00
|
|
|
const rootDir = resolve(__dirname, '../test/fixtures', name)
|
2018-03-23 08:54:11 +00:00
|
|
|
return execa(nuxtBuild, [rootDir])
|
2018-03-18 20:11:43 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 05:17:48 +00:00
|
|
|
const tasks = []
|
|
|
|
for (let fixture of fixtures) {
|
|
|
|
tasks.push({
|
|
|
|
title: 'Building fixtures ' + fixture,
|
|
|
|
task: (ctx, task) => buildFixture(fixture)
|
|
|
|
.then(() => {
|
|
|
|
task.title = task.title.replace(/^Building/, 'Built') + ' Successfully'
|
|
|
|
})
|
|
|
|
})
|
2018-03-18 20:11:43 +00:00
|
|
|
}
|
|
|
|
|
2018-03-19 06:20:13 +00:00
|
|
|
const options = {
|
2018-03-21 01:44:50 +00:00
|
|
|
renderer: isCI ? 'silent' : 'default',
|
2018-03-19 06:20:13 +00:00
|
|
|
nonTTYRenderer: 'silent',
|
|
|
|
concurrent: Math.min(4, cpus().length)
|
|
|
|
}
|
2018-03-19 05:17:48 +00:00
|
|
|
new Listr([{
|
2018-03-19 06:20:13 +00:00
|
|
|
title: `Build ${fixtures.length} fixtures with concurrency of ${options.concurrent}`,
|
|
|
|
task: () => new Listr(tasks, {concurrent: options.concurrent})
|
|
|
|
}], options)
|
2018-03-19 05:17:48 +00:00
|
|
|
.run()
|
2018-03-18 20:11:43 +00:00
|
|
|
.then(() => process.exit(0))
|
2018-03-19 06:54:14 +00:00
|
|
|
.catch((err) => {
|
2018-03-23 08:54:11 +00:00
|
|
|
console.error(err.stderr) // eslint-disable-line no-console
|
2018-03-19 06:54:14 +00:00
|
|
|
process.exit(1)
|
|
|
|
})
|