2018-03-18 23:41:14 +00:00
|
|
|
import path from 'path'
|
|
|
|
import fs from 'fs'
|
2018-03-27 22:28:17 +00:00
|
|
|
|
2018-03-19 07:22:35 +00:00
|
|
|
import _getPort from 'get-port'
|
2018-03-19 04:21:04 +00:00
|
|
|
import { defaultsDeep } from 'lodash'
|
2018-03-27 22:28:17 +00:00
|
|
|
import _rp from 'request-promise-native'
|
2018-04-05 08:38:54 +00:00
|
|
|
import esm from 'esm'
|
2018-03-27 22:28:17 +00:00
|
|
|
import pkg from '../../package.json'
|
|
|
|
import Dist from '../../lib/nuxt'
|
|
|
|
|
|
|
|
export const rp = _rp
|
|
|
|
export const getPort = _getPort
|
|
|
|
export const version = pkg.version
|
2018-03-18 23:41:14 +00:00
|
|
|
|
2018-03-27 22:28:17 +00:00
|
|
|
export const Nuxt = Dist.Nuxt
|
|
|
|
export const Utils = Dist.Utils
|
|
|
|
export const Options = Dist.Options
|
|
|
|
export const Builder = Dist.Builder
|
|
|
|
export const Generator = Dist.Generator
|
|
|
|
|
2018-04-05 08:38:54 +00:00
|
|
|
const requireModule = esm(module, {})
|
|
|
|
|
2018-03-27 22:28:17 +00:00
|
|
|
export const loadFixture = function loadFixture(fixture, overrides) {
|
2018-03-18 23:41:14 +00:00
|
|
|
const rootDir = path.resolve(__dirname, '../fixtures/' + fixture)
|
|
|
|
const configFile = path.resolve(rootDir, 'nuxt.config.js')
|
|
|
|
|
2018-04-05 08:38:54 +00:00
|
|
|
const config = fs.existsSync(configFile) ? requireModule(configFile).default : {}
|
2018-03-18 23:41:14 +00:00
|
|
|
|
|
|
|
config.rootDir = rootDir
|
|
|
|
config.dev = false
|
|
|
|
|
2018-03-19 04:21:04 +00:00
|
|
|
return defaultsDeep({}, overrides, config)
|
2018-03-18 23:41:14 +00:00
|
|
|
}
|