Skip to content

Commit 274662a

Browse files
authored
feat(fmt): align successful format check output (#440)
1 parent 2f715f0 commit 274662a

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/rstack/src/fmt/cli.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ const logFmtResult = (
205205
return;
206206
}
207207

208-
const time = color.bold(formatDuration(durationMilliseconds));
208+
const time = formatDuration(durationMilliseconds);
209209

210210
if (mode === 'write') {
211211
if (writtenCount === 0 && result.exitCode !== 0) {
@@ -230,9 +230,8 @@ const logFmtResult = (
230230
logger.error(`Formatting issues found in ${differentFiles}. ${fixHint}`);
231231
logger.info(`Checked ${processedFiles} in ${time}.`);
232232
} else if (result.exitCode === 0) {
233-
logger.success(
234-
`Checked ${formatFileCount(processedFileCount)} in ${time}. No issues found.`,
235-
);
233+
const files = `${processedFileCount} ${processedFileCount === 1 ? 'file' : 'files'}`;
234+
logger.success(`Format check passed in ${time} ${color.dim(`(${files})`)}`);
236235
}
237236
};
238237

packages/rstack/tests/cli/check.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test('runs lint followed by a formatting check', () => {
4444
const formatted = runCheck();
4545

4646
expect(formatted.status).toBe(0);
47-
expect(formatted.stdout).toContain('No issues found.');
47+
expect(formatted.stdout).toContain('Format check passed in');
4848
expect(formatted.stderr).toBe('');
4949
});
5050

packages/rstack/tests/cli/fmt/files.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test('checks formatting without writing files', () => {
117117

118118
expect(formattedResult.status).toBe(0);
119119
expect(normalizeDuration(formattedResult.stdout)).toBe(
120-
'start Checking formatting...\nsuccess Checked 1 file in <duration>. No issues found.\n',
120+
'start Checking formatting...\nsuccess Format check passed in <duration> (1 file)\n',
121121
);
122122
expect(formattedResult.stderr).toBe('');
123123
});

packages/rstack/tests/cli/fmt/patterns.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ test('allows no files to match with --no-error-on-unmatched-pattern', () => {
3333

3434
test('counts only supported files', () => {
3535
writeProjectFile('index.ts', 'const value = 1;\n');
36+
writeProjectFile('other.ts', 'const other = 2;\n');
3637
writeProjectFile('notes.unknown', 'plain text');
3738

38-
const result = runFmt(['--check', 'index.ts', 'notes.unknown']);
39+
const result = runFmt(['--check', 'index.ts', 'other.ts', 'notes.unknown']);
3940

4041
expect(result.status).toBe(0);
4142
expect(normalizeDuration(result.stdout)).toBe(
42-
'start Checking formatting...\nsuccess Checked 1 file in <duration>. No issues found.\n',
43+
'start Checking formatting...\nsuccess Format check passed in <duration> (2 files)\n',
4344
);
4445
expect(result.stderr).toBe('');
4546
});

0 commit comments

Comments
 (0)