Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 27, 2022
1 parent 4a6299c commit 5b55927
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/config/load/cwd.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const addBases = function (configContents, base) {
}

const addBaseProps = function (value, base) {
return canRecurse(value) && !Array.isArray(value)
return shouldAddBaseProps(value)
? Object.fromEntries(
Object.entries(value).flatMap(addBaseProp.bind(undefined, base)),
)
Expand All @@ -93,15 +93,17 @@ export const removeBases = function (configWithBases) {
}

const removeBaseProps = function (value) {
return canRecurse(value) && !Array.isArray(value)
? filterObj(value, isNotBaseProp)
: value
return shouldAddBaseProps(value) ? filterObj(value, isNotBaseProp) : value
}

const isNotBaseProp = function (key) {
return !key.endsWith(BASE_KEY_SUFFIX) && !key.endsWith(BASE_ITEMS_SUFFIX)
}

const shouldAddBaseProps = function (value) {
return canRecurse(value) && !Array.isArray(value)
}

const BASE_KEY_SUFFIX = 'CwdBase'
const BASE_ITEMS_SUFFIX = 'ItemsCwdBase'

Expand Down

0 comments on commit 5b55927

Please sign in to comment.