Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/cli/src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export default defineCommand({
return;
}

console.log(serializeTailwindV4(result.data.theme));
// serializeTailwindV4 already ends with a single trailing newline; avoid console.log's extra newline.
process.stdout.write(serializeTailwindV4(result.data.theme));
} else if (format === 'json-tailwind' || format === 'tailwind') {
const handler = new TailwindEmitterHandler();
const result = handler.execute(report.designSystem);
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/linter/tailwind/v4/serialize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@ describe('serializeToCss', () => {
const out = serializeToCss(data);
expect(out).toContain('--font-body: "Google Sans Display";');
});

it('ends with exactly one trailing newline (for stdout.write export path)', () => {
const out = serializeToCss({ colors: { primary: '#000000', 'on-primary': '#ffffff' } });
expect(out.endsWith('\n')).toBe(true);
expect(out.endsWith('\n\n')).toBe(false);
});
});
9 changes: 6 additions & 3 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ export async function readInput(filePath: string): Promise<string> {
try {
return readFileSync(filePath, 'utf-8');
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
const hint = message.includes('ENOENT')
? `Design file not found: ${filePath}. Create a DESIGN.md or pass an existing path.`
: message;
console.error(JSON.stringify({
error: 'FILE_READ_ERROR',
message: error instanceof Error ? error.message : String(error),
message: hint,
path: filePath,
}));
process.exitCode = 2;
throw error; // bubbles up, but process will exit with code 2 if uncaught
process.exit(2);
}
}

Expand Down