Skip to content

Commit

Permalink
refactor: skip variants that doesnt have rule as a function
Browse files Browse the repository at this point in the history
  • Loading branch information
vitoUwu committed Dec 8, 2024
1 parent 99228f2 commit 9059b24
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions blocks/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ const flagBlock: Block<BlockModule<FlagFunc>> = {
let match: Variant<unknown> | null = null;

for (const variant of flag.variants || []) {
let ruleResult = typeof variant?.rule === "function"
? variant?.rule(ctx)
: null;
if (typeof variant?.rule !== "function") {
continue;
}
let ruleResult = variant?.rule(ctx);
// the rule can sometimes be a promise and we need to await it to check if it's truthy or not
if (isAwaitable(ruleResult)) {
try {
Expand Down

0 comments on commit 9059b24

Please sign in to comment.