-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35481cd
commit fe194e1
Showing
2 changed files
with
15 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import { existsSync } from 'fs' | ||
import merge from 'lodash.merge' | ||
|
||
import * as defaultConfig from './config.mjs' | ||
|
||
export async function loadConfig(configFileRoute, { logger }) { | ||
try { | ||
if (existsSync(configFileRoute)) { | ||
logger.info('ℹ️ Loading spark-ui custom configuration file') | ||
const { default: customConfig } = await import(configFileRoute) | ||
|
||
return customConfig | ||
const config = { | ||
adoption: merge(defaultConfig, { | ||
...customConfig.adoption, | ||
imports: customConfig.imports || defaultConfig.imports, | ||
extensions: customConfig.extensions || defaultConfig.extensions, | ||
}), | ||
} | ||
|
||
return config | ||
} else { | ||
logger.warn('⚠️ No custom configuration file found') | ||
logger.info('ℹ️ Loading default configuration') | ||
|
||
return {} | ||
return { ...defaultConfig } | ||
} | ||
} catch (error) { | ||
logger.error('💥 Something went wrong loading the custom configuration file') | ||
|
||
return {} | ||
return { ...defaultConfig } | ||
} | ||
} |