mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
67 lines
1.4 KiB
JavaScript
Executable File
67 lines
1.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
process.env.NODE_ENV = 'test'
|
|
|
|
const { resolve } = require('path')
|
|
const { cpus } = require('os')
|
|
|
|
const execa = require('execa')
|
|
const Listr = require('listr')
|
|
const isCI = require('is-ci')
|
|
|
|
const fixtures = [
|
|
'children',
|
|
'custom-dirs',
|
|
'debug',
|
|
'deprecate',
|
|
'dynamic-routes',
|
|
'empty',
|
|
'error',
|
|
'module',
|
|
'ssr',
|
|
'with-config',
|
|
|
|
// csr,
|
|
// dev,
|
|
// generate,
|
|
// fail generate,
|
|
// fallback generate,
|
|
// ssr,
|
|
// ssr csp,
|
|
// spa
|
|
'basic'
|
|
]
|
|
|
|
const nuxtBuild = resolve(__dirname, '../bin/nuxt-build')
|
|
|
|
function buildFixture(name) {
|
|
const rootDir = resolve(__dirname, '../test/fixtures', name)
|
|
return execa(nuxtBuild, [rootDir])
|
|
}
|
|
|
|
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'
|
|
})
|
|
})
|
|
}
|
|
|
|
const options = {
|
|
renderer: isCI ? 'silent' : 'default',
|
|
nonTTYRenderer: 'silent',
|
|
concurrent: Math.min(4, cpus().length)
|
|
}
|
|
new Listr([{
|
|
title: `Build ${fixtures.length} fixtures with concurrency of ${options.concurrent}`,
|
|
task: () => new Listr(tasks, {concurrent: options.concurrent})
|
|
}], options)
|
|
.run()
|
|
.then(() => process.exit(0))
|
|
.catch((err) => {
|
|
console.error(err.stderr) // eslint-disable-line no-console
|
|
process.exit(1)
|
|
})
|