Skip to content

Commit c48ec3e

Browse files
authored
fix(cli): text not readable in light terminals (#838)
With `chalk.white`, the text is hard to read on terminals with light backgrounds. `chalk.reset` works as expected in both dark and light background. Fixes #751 --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license
1 parent 0e1dec4 commit c48ec3e

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

packages/@aws-cdk/cloudformation-diff/lib/format.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class Formatter {
9898
}
9999

100100
public print(fmt: string, ...args: any[]) {
101-
this.stream.write(chalk.white(format(fmt, ...args)) + '\n');
101+
this.stream.write(chalk.reset(format(fmt, ...args)) + '\n');
102102
}
103103

104104
public warning(fmt: string, ...args: any[]) {
@@ -204,7 +204,7 @@ export class Formatter {
204204
if (diff.isRemoval) {
205205
return REMOVAL;
206206
}
207-
return chalk.white('[?]');
207+
return chalk.reset('[?]');
208208
}
209209

210210
/**

packages/@aws-cdk/toolkit-lib/lib/toolkit/non-interactive-io-host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ export class NonInteractiveIoHost implements IIoHost {
156156
const styleMap: Record<IoMessageLevel, (str: string) => string> = {
157157
error: chalk.red,
158158
warn: chalk.yellow,
159-
result: chalk.white,
160-
info: chalk.white,
159+
result: chalk.reset,
160+
info: chalk.reset,
161161
debug: chalk.gray,
162162
trace: chalk.gray,
163163
};

packages/aws-cdk/lib/cli/io-host/cli-io-host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,8 @@ function extractPromptInfo(msg: IoRequest<any, any>): {
536536
const styleMap: Record<IoMessageLevel, (str: string) => string> = {
537537
error: chalk.red,
538538
warn: chalk.yellow,
539-
result: chalk.white,
540-
info: chalk.white,
539+
result: chalk.reset,
540+
info: chalk.reset,
541541
debug: chalk.gray,
542542
trace: chalk.gray,
543543
};

packages/aws-cdk/test/cli/io-host/cli-io-host.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('CliIoHost', () => {
8484
message: 'test message',
8585
}));
8686

87-
expect(mockStderr).toHaveBeenCalledWith(chalk.white('test message') + '\n');
87+
expect(mockStderr).toHaveBeenCalledWith(chalk.reset('test message') + '\n');
8888
expect(mockStdout).not.toHaveBeenCalled();
8989
});
9090

@@ -112,7 +112,7 @@ describe('CliIoHost', () => {
112112
message: 'result message',
113113
}));
114114

115-
expect(mockStdout).toHaveBeenCalledWith(chalk.white('result message') + '\n');
115+
expect(mockStdout).toHaveBeenCalledWith(chalk.reset('result message') + '\n');
116116
expect(mockStderr).not.toHaveBeenCalled();
117117
});
118118
});
@@ -184,7 +184,7 @@ describe('CliIoHost', () => {
184184
test.each([
185185
['error', 'red', false],
186186
['warn', 'yellow', false],
187-
['info', 'white', false],
187+
['info', 'reset', false],
188188
['debug', 'gray', true],
189189
['trace', 'gray', true],
190190
] as Array<[IoMessageLevel, typeof chalk.ForegroundColor, boolean]>)('outputs %ss in %s color ', async (level, color, shouldAddTime) => {
@@ -229,7 +229,7 @@ describe('CliIoHost', () => {
229229
message: 'ci message',
230230
}));
231231

232-
expect(mockStdout).toHaveBeenCalledWith(chalk.white('ci message') + '\n');
232+
expect(mockStdout).toHaveBeenCalledWith(chalk.reset('ci message') + '\n');
233233
expect(mockStderr).not.toHaveBeenCalled();
234234
});
235235

@@ -275,7 +275,7 @@ describe('CliIoHost', () => {
275275
message: 'info message',
276276
}));
277277

278-
expect(mockStderr).toHaveBeenCalledWith(chalk.white('info message') + '\n');
278+
expect(mockStderr).toHaveBeenCalledWith(chalk.reset('info message') + '\n');
279279
});
280280
});
281281

@@ -505,7 +505,7 @@ describe('CliIoHost', () => {
505505
defaultResponse: [1, 2, 3],
506506
}));
507507

508-
expect(mockStderr).toHaveBeenCalledWith(chalk.white('test message') + '\n');
508+
expect(mockStderr).toHaveBeenCalledWith(chalk.reset('test message') + '\n');
509509
expect(response).toEqual([1, 2, 3]);
510510
});
511511
});

0 commit comments

Comments
 (0)