Skip to content

Commit

Permalink
refactor: move check and update warning
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 5, 2022
1 parent ac88c8f commit 7ee2658
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ async function extendConfig (config, opts: LoadConfigOptions) {
delete config[key]
}
for (const extendSource of extendSources) {
if (typeof extendSource !== 'string') {
// TODO: Use error in next major versions
// eslint-disable-next-line no-console
console.warn(`Cannot extend config from \`${JSON.stringify(extendSource)}\` (which should be a string) in ${opts.cwd}`)
continue
}
const _config = await resolveConfig(extendSource, opts)
if (!_config.config) {
// TODO: Use error in next major versions
// eslint-disable-next-line no-console
console.warn(`Cannot extend config from ${JSON.stringify(extendSource)} in ${opts.cwd}`)
console.warn(`Cannot extend config from \`${extendSource}\` in ${opts.cwd}`)
continue
}
await extendConfig(_config.config, { ...opts, cwd: _config.cwd })
Expand All @@ -161,12 +167,6 @@ const NPM_PACKAGE_RE = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/
const jiti = createJiti(null, { cache: false, interopDefault: true, requireCache: false, esmResolve: true })

async function resolveConfig (source: string, opts: LoadConfigOptions): Promise<ResolvedConfig> {
if (typeof source !== 'string') {
// TODO: Remove in next major version
// @ts-expect-error deliberately trigger warning in L142-144
return {}
}

// Custom user resolver
if (opts.resolve) {
const res = await opts.resolve(source, opts)
Expand Down

0 comments on commit 7ee2658

Please sign in to comment.