Skip to content

Commit 67600ad

Browse files
committed
fix: cjs import
1 parent 0459852 commit 67600ad

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

src/cli.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/usr/bin/env -S npx tsx
1+
#!/usr/bin/env node
2+
import "tsx";
23

34
import { writeFile } from "node:fs/promises";
45
import { resolve } from "node:path";

src/generate.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ ${isDefault ? '@custom-variant dark (&:where([data-mantine-color-scheme="dark"],
143143
}
144144
145145
/* colors - all */
146-
${Object.keys(theme.colors)
146+
${Object.keys(theme.colors ?? {})
147147
.map((key) =>
148148
`
149149
--color-${key}-50: rgb(from var(--mantine-color-${key}-0) r g b / <alpha-value>);
@@ -162,7 +162,7 @@ ${isDefault ? '@custom-variant dark (&:where([data-mantine-color-scheme="dark"],
162162
.join("\n")}
163163
164164
/* colors - variant specific */
165-
${Object.keys(theme.colors)
165+
${Object.keys(theme.colors ?? {})
166166
.map((key) =>
167167
`
168168
--color-${key}-filled: rgb(from var(--mantine-color-${key}-filled) r g b / <alpha-value>);
@@ -177,7 +177,7 @@ ${isDefault ? '@custom-variant dark (&:where([data-mantine-color-scheme="dark"],
177177
.join("\n")}
178178
179179
/* breakpoints */
180-
${Object.entries(theme.breakpoints)
180+
${Object.entries(theme.breakpoints ?? {})
181181
.map(([key, value]) =>
182182
`
183183
--breakpoint-${key}: ${value};

test/cli.test.js

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ test("processes custom TS theme", async (t) => {
9797
await testThemeGeneration(inputPath, "custom-theme-ts-output.css");
9898
});
9999

100+
// Test: CLI should process CJS theme
101+
test("processes CJS theme", async (t) => {
102+
const inputPath = join(FIXTURES_DIR, "cjs-theme.cjs");
103+
await testThemeGeneration(inputPath, "cjs-theme-output.css");
104+
});
105+
100106
// Test: CLI should handle custom output path
101107
test("handles custom output path with --output flag", async (t) => {
102108
const inputPath = join(FIXTURES_DIR, "default-theme.js");

test/fixtures/cjs-theme.cjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { createTheme } = require("@mantine/core");
2+
3+
module.exports = createTheme({
4+
colors: {
5+
"deep-red": [
6+
"#ffeaec",
7+
"#fcd4d7",
8+
"#f4a7ac",
9+
"#ec777e",
10+
"#e64f57",
11+
"#e3353f",
12+
"#e22732",
13+
"#c91a25",
14+
"#b41220",
15+
"#9e0419",
16+
],
17+
},
18+
});

0 commit comments

Comments
 (0)