chore: simplify loadFixture

This commit is contained in:
pooya parsa 2019-01-20 22:20:01 +03:30
parent 2f2ec7ac30
commit e1d4dd59c7

View File

@ -16,12 +16,13 @@ export const loadFixture = async function (fixture, overrides) {
const rootDir = path.resolve(__dirname, '..', 'fixtures', fixture)
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`)
config = config.default || config
break
try {
await import(`../fixtures/${fixture}/nuxt.config`)
config = config.default || config
} catch (e) {
// Ignore MODULE_NOT_FOUND
if (e.code !== 'MODULE_NOT_FOUND') {
throw e
}
}