chore: simplify loadFixture

This commit is contained in:
pooya parsa 2019-01-20 22:20:01 +03:30
parent 2f2ec7ac30
commit e1d4dd59c7
1 changed files with 7 additions and 6 deletions

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`)
try {
await import(`../fixtures/${fixture}/nuxt.config`)
config = config.default || config
break
} catch (e) {
// Ignore MODULE_NOT_FOUND
if (e.code !== 'MODULE_NOT_FOUND') {
throw e
}
}