Skip to content

Commit 7c352bf

Browse files
tcelyphilschatz
authored andcommitted
rules: allow more than a single rule per card (#50)
Before any rules with the same name on a single card would overwrite the earlier instances.
1 parent 05ca4f9 commit 7c352bf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/extract-rules.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ const commonmarkParser = new commonmark.Parser()
1313
// ```
1414
function parseMarkdown (card) {
1515
if (!card.note) {
16-
return new Map() // no Rules
16+
return [] // no Rules
1717
}
1818
const root = commonmarkParser.parse(card.note)
1919
const walker = root.walker()
20-
const parsedRules = new Map()
20+
const parsedRules = []
2121
let walkEvent
2222
while ((walkEvent = walker.next())) {
2323
const {node} = walkEvent
@@ -38,7 +38,7 @@ function parseMarkdown (card) {
3838
if (args.length === 0 && node.next && node.next.literal) {
3939
args = node.next.literal.trim().split(' ').map((arg) => arg.trim())
4040
}
41-
parsedRules.set(node.literal, args)
41+
parsedRules.push({ ruleName: node.literal, ruleArgs: args})
4242
}
4343
}
4444
}
@@ -64,11 +64,11 @@ module.exports = function extractAutomationRules (projects) {
6464

6565
allCards.forEach(({card, column}) => {
6666
const rules = parseMarkdown(card)
67-
rules.forEach((ruleArgs, ruleName) => {
67+
rules.forEach((r) => {
6868
automationRules.push({
6969
column,
70-
ruleName,
71-
ruleArgs
70+
r.ruleName,
71+
r.ruleArgs
7272
})
7373
})
7474
})

0 commit comments

Comments
 (0)