Skip to content

Commit

Permalink
Allow nested rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 5, 2022
1 parent 22904ab commit d8783a1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/config/normalize/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const applyRules = async function ({
// mutated.
const applyParallelRules = async function ({ items, state, keywords, sync }) {
const resolutions = await Promise.allSettled(
items.map((rule) => applyRuleDeep({ state, rule, keywords, sync })),
items.map((item) => applyRulesOrRule({ state, item, keywords, sync })),
)
handleFailedRule(resolutions)
}
Expand All @@ -74,13 +74,19 @@ const isFailedRule = function ({ status }) {

const applySerialRules = async function ({ items, state, keywords, sync }) {
// eslint-disable-next-line fp/no-loops
for (const rule of items) {
for (const item of items) {
// eslint-disable-next-line no-await-in-loop
await applyRuleDeep({ state, rule, keywords, sync })
await applyRulesOrRule({ state, item, keywords, sync })
}
}

const applyRuleDeep = async function ({
const applyRulesOrRule = async function ({ state, item, keywords, sync }) {
await (item.name === undefined
? applyRules({ state, rules: item, keywords, sync })
: applyRule({ state, rule: item, keywords, sync }))
}

const applyRule = async function ({
state,
state: { inputs },
rule,
Expand Down

0 comments on commit d8783a1

Please sign in to comment.