Skip to content

Commit 42f54db

Browse files
committed
feat: add emoji test loom
1 parent 9078bd7 commit 42f54db

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/generators/emoji-test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { z } from "zod";
2+
import { createLoom } from "../loom";
3+
4+
const entry = z.object({
5+
codePoints: z.array(z.string()),
6+
status: z.union([
7+
z.literal("component"),
8+
z.literal("fully-qualified"),
9+
z.literal("minimally-qualified"),
10+
z.literal("unqualified"),
11+
]),
12+
comment: z.string(),
13+
});
14+
15+
const emojiTestInputSchema = z.object({
16+
group: z.string(),
17+
subgroups: z.array(z.object({
18+
subgroup: z.string(),
19+
entries: z.array(entry),
20+
})),
21+
});
22+
23+
const emojiTestOptionsSchema = z.object({
24+
separator: z.string(),
25+
commentPrefix: z.string(),
26+
version: z.string(),
27+
});
28+
29+
export const emojiTest = createLoom({
30+
inputSchema: emojiTestInputSchema,
31+
optionsSchema: emojiTestOptionsSchema,
32+
predicate: (ctx) => {
33+
return ctx.isVersionLowerThan("3.x");
34+
},
35+
template: (ctx, item) => {
36+
let template = `group: ${item.group}\n`;
37+
38+
for (const subgroup of item.subgroups) {
39+
template += `subgroup: ${subgroup.subgroup}\n`;
40+
41+
for (const entry of subgroup.entries) {
42+
template += `${entry.codePoints.join(" ")} ${ctx.options.separator} ${entry.status} ${ctx.options.commentPrefix} ${entry.comment}\n`;
43+
}
44+
}
45+
46+
return template;
47+
},
48+
});

0 commit comments

Comments
 (0)