Nuxt/scripts/build-fixtures

67 lines
1.4 KiB
Plaintext
Raw Normal View History

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')
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)
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
}
const options = {
2018-03-21 01:44:50 +00:00
renderer: isCI ? 'silent' : 'default',
nonTTYRenderer: 'silent',
concurrent: Math.min(4, cpus().length)
}
2018-03-19 05:17:48 +00:00
new Listr([{
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))
.catch((err) => {
console.error(err.stderr) // eslint-disable-line no-console
process.exit(1)
})