mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
build-fixtures script
This commit is contained in:
parent
ed22e78a75
commit
07c40a913a
@ -47,6 +47,7 @@
|
||||
"setupTestFrameworkScriptFile": "./test/helpers/setup"
|
||||
},
|
||||
"scripts": {
|
||||
"build-fixtures": "./scripts/build-fixtures",
|
||||
"test": "npm run lint && jest",
|
||||
"test-appveyor": "yarn test",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
|
57
scripts/build-fixtures
Executable file
57
scripts/build-fixtures
Executable file
@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.NODE_ENV = 'test'
|
||||
|
||||
const { Builder, Nuxt } = require('..')
|
||||
const { requireModule } = require('../lib/common/module')
|
||||
const path = require('path')
|
||||
const fs = require('fs')
|
||||
const ORA = require('ora')
|
||||
|
||||
const fixtures = [
|
||||
// csr, dev, generate, fail generate, fallback generate, ssr, ssr csp, spa
|
||||
'basic',
|
||||
|
||||
'children',
|
||||
'custom-dirs',
|
||||
'debug',
|
||||
'deprecate',
|
||||
'dynamic-routes',
|
||||
'empty',
|
||||
'error',
|
||||
'module',
|
||||
'ssr',
|
||||
'with-config'
|
||||
]
|
||||
|
||||
const spinner = new ORA()
|
||||
|
||||
async function buildFixture(name) {
|
||||
spinner.info('Loading config for fixture ' + name)
|
||||
|
||||
const rootDir = path.resolve(__dirname, '../test/fixtures', name)
|
||||
const configFile = path.resolve(rootDir, 'nuxt.config.js')
|
||||
const config = fs.existsSync(configFile) ? requireModule(configFile) : {}
|
||||
|
||||
config.rootDir = rootDir
|
||||
|
||||
spinner.start('Building fixture ' + name)
|
||||
|
||||
const nuxt = new Nuxt(config)
|
||||
const builder = new Builder(nuxt)
|
||||
|
||||
await builder.build()
|
||||
|
||||
spinner.succeed('Built fixture ' + name)
|
||||
|
||||
await nuxt.close()
|
||||
}
|
||||
|
||||
async function run() {
|
||||
for (let fixture of fixtures) {
|
||||
await buildFixture(fixture)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
.catch(console.error) // eslint-disable-line no-console
|
||||
.then(() => process.exit(0))
|
Loading…
Reference in New Issue
Block a user