Skip to content

Commit f952592

Browse files
authored
fix: render guide with empty log lines (#436)
1 parent 372b526 commit f952592

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

.changeset/long-friends-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/prompts": patch
3+
---
4+
5+
Fixes missing guide when rendering empty log lines.

packages/prompts/src/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const log = {
4949
if (ln.length > 0) {
5050
parts.push(`${secondaryPrefix}${ln}`);
5151
} else {
52-
parts.push(hasGuide ? '' : secondarySymbol);
52+
parts.push(hasGuide ? secondarySymbol : '');
5353
}
5454
}
5555
}

packages/prompts/test/__snapshots__/log.test.ts.snap

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ exports[`log (isCI = false) > info > renders info message 1`] = `
1616
]
1717
`;
1818

19+
exports[`log (isCI = false) > message > renders empty lines correctly 1`] = `
20+
[
21+
"│
22+
│ foo
23+
│
24+
│ bar
25+
",
26+
]
27+
`;
28+
29+
exports[`log (isCI = false) > message > renders empty lines with guide disabled 1`] = `
30+
[
31+
"
32+
foo
33+
34+
bar
35+
",
36+
]
37+
`;
38+
1939
exports[`log (isCI = false) > message > renders empty message correctly 1`] = `
2040
[
2141
"│
@@ -137,6 +157,26 @@ exports[`log (isCI = true) > info > renders info message 1`] = `
137157
]
138158
`;
139159

160+
exports[`log (isCI = true) > message > renders empty lines correctly 1`] = `
161+
[
162+
"│
163+
│ foo
164+
│
165+
│ bar
166+
",
167+
]
168+
`;
169+
170+
exports[`log (isCI = true) > message > renders empty lines with guide disabled 1`] = `
171+
[
172+
"
173+
foo
174+
175+
bar
176+
",
177+
]
178+
`;
179+
140180
exports[`log (isCI = true) > message > renders empty message correctly 1`] = `
141181
[
142182
"│

packages/prompts/test/log.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,23 @@ describe.each(['true', 'false'])('log (isCI = %s)', (isCI) => {
102102

103103
expect(output.buffer).toMatchSnapshot();
104104
});
105+
106+
test('renders empty lines correctly', () => {
107+
prompts.log.message('foo\n\nbar', {
108+
output,
109+
});
110+
111+
expect(output.buffer).toMatchSnapshot();
112+
});
113+
114+
test('renders empty lines with guide disabled', () => {
115+
prompts.log.message('foo\n\nbar', {
116+
withGuide: false,
117+
output,
118+
});
119+
120+
expect(output.buffer).toMatchSnapshot();
121+
});
105122
});
106123

107124
describe('info', () => {

0 commit comments

Comments
 (0)