fix(test/utils): check both ts and js for nuxt.config

This commit is contained in:
pooya parsa 2019-01-20 22:13:27 +03:30
parent b0ca62d0c7
commit 5b66afc23a

View File

@ -14,9 +14,16 @@ export const version = `v${coreVersion}`
export const loadFixture = async function (fixture, overrides) {
const rootDir = path.resolve(__dirname, '..', 'fixtures', fixture)
const configFile = path.resolve(rootDir, `nuxt.config${process.env.NUXT_TS === 'true' ? '.ts' : '.js'}`)
let config = {}
for (const ext of ['ts', 'js']) {
const configFile = path.resolve(rootDir, `nuxt.config.${ext}`)
if (fs.existsSync(configFile)) {
config = (await import(`../fixtures/${fixture}/nuxt.config`)).default
break
}
}
let config = fs.existsSync(configFile) ? (await import(`../fixtures/${fixture}/nuxt.config`)).default : {}
if (typeof config === 'function') {
config = await config()
}