Skip to content

Commit

Permalink
fix(cli-utils): merge values
Browse files Browse the repository at this point in the history
  • Loading branch information
andresin87 committed Jun 19, 2024
1 parent 35481cd commit fe194e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/utils/cli/src/scan/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function adoption(options) {
adoption: merge(
{ ...config.adoption },
{
...optionsConfig.adoption,
...optionsConfig,
imports: optionsConfig.imports || config.imports,
extensions: optionsConfig.extensions || config.extensions,
}
Expand Down
17 changes: 14 additions & 3 deletions packages/utils/cli/src/scan/loadConfig.mjs
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 }
}
}

0 comments on commit fe194e1

Please sign in to comment.