Skip to content

Commit 75b1a24

Browse files
committed
wip: add Logger#clearScreen method
1 parent 8af66fc commit 75b1a24

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/codegen/src/logger/formatter.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dedent from 'dedent';
22
import ts from 'typescript';
3-
import { describe, expect, it } from 'vitest';
3+
import { describe, expect, test } from 'vitest';
44
import { formatDiagnostics } from './formatter';
55

66
describe('formatDiagnostics', () => {
@@ -38,7 +38,7 @@ describe('formatDiagnostics', () => {
3838
},
3939
];
4040

41-
it('formats diagnostics with color and context when pretty is true', () => {
41+
test('formats diagnostics with color and context when pretty is true', () => {
4242
const result = formatDiagnostics(diagnostics, host, true);
4343
expect(result).toMatchInlineSnapshot(`
4444
"test.module.css:1:2 - error: \`a_1\` is not allowed
@@ -55,7 +55,7 @@ describe('formatDiagnostics', () => {
5555
`);
5656
});
5757

58-
it('formats diagnostics without color and context when pretty is false', () => {
58+
test('formats diagnostics without color and context when pretty is false', () => {
5959
const result = formatDiagnostics(diagnostics, host, false);
6060
expect(result).toMatchInlineSnapshot(`
6161
"test.module.css(1,2): error: \`a_1\` is not allowed

packages/codegen/src/logger/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface Logger {
88
logDiagnostics(diagnostics: Diagnostic[]): void;
99
logError(error: unknown): void;
1010
logMessage(message: string): void;
11+
clearScreen(): void;
1112
}
1213

1314
export function createLogger(cwd: string, pretty: boolean): Logger {
@@ -45,5 +46,8 @@ export function createLogger(cwd: string, pretty: boolean): Logger {
4546
logMessage(message: string): void {
4647
process.stdout.write(`${message}\n`);
4748
},
49+
clearScreen(): void {
50+
process.stdout.write('\x1B[2J\x1B[3J\x1B[H');
51+
},
4852
};
4953
}

packages/codegen/src/test/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export function createLoggerSpy() {
66
logDiagnostics: vi.fn(),
77
logError: vi.fn(),
88
logMessage: vi.fn(),
9+
clearScreen: vi.fn(),
910
} satisfies Logger;
1011
}

0 commit comments

Comments
 (0)