Nuxt/scripts/build-fixtures

66 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 spawnAsync = require('@expo/spawn-async')
2018-03-19 05:17:48 +00:00
const Listr = require('listr')
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-19 05:17:48 +00:00
return spawnAsync('node', [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-19 06:37:19 +00:00
renderer: process.env.CI ? '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) // eslint-disable-line no-console
process.exit(1)
})