(frontmatter: UnknownRecord, taskType: TaskTypeDefLike | undefined)
| 123 | } |
| 124 | |
| 125 | function applyMatchDefaults(frontmatter: UnknownRecord, taskType: TaskTypeDefLike | undefined): void { |
| 126 | const where = taskType?.match?.where; |
| 127 | if (!where || typeof where !== "object") return; |
| 128 | |
| 129 | for (const [field, condition] of Object.entries(where)) { |
| 130 | if (condition === null || condition === undefined) continue; |
| 131 | |
| 132 | if (typeof condition !== "object" || Array.isArray(condition)) { |
| 133 | if (!hasValue(frontmatter[field])) { |
| 134 | frontmatter[field] = condition; |
| 135 | } |
| 136 | continue; |
| 137 | } |
| 138 | |
| 139 | const ops = condition as Record<string, unknown>; |
| 140 | if ("eq" in ops && !hasValue(frontmatter[field])) { |
| 141 | frontmatter[field] = ops.eq; |
| 142 | continue; |
| 143 | } |
| 144 | |
| 145 | if ("contains" in ops) { |
| 146 | const expected = ops.contains; |
| 147 | const current = frontmatter[field]; |
| 148 | if (Array.isArray(current)) { |
| 149 | if (!current.some((v) => String(v) === String(expected))) { |
| 150 | current.push(expected); |
| 151 | frontmatter[field] = current; |
| 152 | } |
| 153 | continue; |
| 154 | } |
| 155 | if (typeof current === "string") { |
| 156 | if (!current.includes(String(expected))) { |
| 157 | frontmatter[field] = `${current} ${String(expected)}`.trim(); |
| 158 | } |
| 159 | continue; |
| 160 | } |
| 161 | if (!hasValue(current)) { |
| 162 | frontmatter[field] = [expected]; |
| 163 | } |
| 164 | continue; |
| 165 | } |
| 166 | |
| 167 | if ("exists" in ops && ops.exists === true && !hasValue(frontmatter[field])) { |
| 168 | frontmatter[field] = true; |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | function derivePathFromType( |
| 174 | taskType: TaskTypeDefLike | undefined, |
no test coverage detected