Nuxt/test/utils/nuxt.js

28 lines
970 B
JavaScript
Raw Normal View History

2018-10-24 13:53:34 +00:00
import path from 'path'
import fs from 'fs'
import { defaultsDeep } from 'lodash'
export { version } from '../../packages/core/package.json'
export { Nuxt } from '../../packages/core/src/index'
export { Builder } from '../../packages/builder/src/index'
export { Generator } from '../../packages/generator/src/index'
export { BundleBuilder } from '../../packages/webpack/src/index'
2018-12-22 21:05:13 +00:00
export * from '../../packages/utils/src/index'
2018-10-24 13:53:34 +00:00
export const loadFixture = async function (fixture, overrides) {
const rootDir = path.resolve(__dirname, '..', 'fixtures', fixture)
2019-01-04 19:30:28 +00:00
const configFile = path.resolve(rootDir, `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`)
2018-10-24 13:53:34 +00:00
let config = fs.existsSync(configFile) ? (await import(`../fixtures/${fixture}/nuxt.config`)).default : {}
if (typeof config === 'function') {
config = await config()
}
config.rootDir = rootDir
config.dev = false
config.test = true
return defaultsDeep({}, overrides, config)
2018-10-24 14:00:50 +00:00
}