Skip to content
Merged
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
6 changes: 5 additions & 1 deletion packages/rstack/src/fmt/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ const runFmtCLI = async (args: string[]): Promise<void> => {
}
}

if (mode === 'check') {
if (mode === 'write') {
logger.start('Formatting...');
} else if (mode === 'check') {
logger.start('Checking formatting...');
}

Expand All @@ -350,6 +352,8 @@ const runFmtCLI = async (args: string[]): Promise<void> => {
if (ignoreUnknown) {
if (mode === 'check') {
logger.success('No supported files to check.');
} else if (mode === 'write') {
logger.success('No supported files to format.');
}
return;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/rstack/tests/cli/fmt/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ test('returns exit code 2 for formatting errors', () => {
const result = runFmt(['index.ts']);

expect(result.status).toBe(2);
expect(result.stdout).toBe('');
expect(result.stdout).toBe('start Formatting...\n');
expect(result.stderr).toContain('error index.ts: SyntaxError:');
});

Expand All @@ -148,7 +148,9 @@ test('reports partial writes when formatting fails', () => {
const result = runFmt(['valid.ts', 'invalid.ts']);

expect(result.status).toBe(2);
expect(normalizeDuration(result.stdout)).toBe('info Formatted 1 of 2 files in <duration>.\n');
expect(normalizeDuration(result.stdout)).toBe(
'start Formatting...\ninfo Formatted 1 of 2 files in <duration>.\n',
);
expect(result.stderr).toContain('error invalid.ts: SyntaxError:');
expect(readProjectFile('valid.ts')).toBe('const value = true;\n');
expect(readProjectFile('invalid.ts')).toBe('const invalid = ;');
Expand Down
2 changes: 1 addition & 1 deletion packages/rstack/tests/cli/fmt/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const expectWriteSummary = (
const message = writtenCount
? `Formatted ${writtenCount} of ${matchedFileCount} ${files} in <duration>.`
: `Checked ${matchedFileCount} ${files} in <duration>. No changes needed.`;
expect(normalizeDuration(output)).toBe(`success ${message}\n`);
expect(normalizeDuration(output)).toBe(`start Formatting...\nsuccess ${message}\n`);
};

export const setupFmtTest = (): FmtTestHarness => {
Expand Down
15 changes: 8 additions & 7 deletions packages/rstack/tests/cli/fmt/patterns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ test('ignores unsupported files with --ignore-unknown', () => {
const result = runFmt([...modeArgs, '--ignore-unknown', 'notes.unknown']);

expect(result.status).toBe(0);
expect(result.stdout).toBe(
modeArgs.includes('--check')
? 'start Checking formatting...\nsuccess No supported files to check.\n'
: '',
);
const expectedStdout = modeArgs.includes('--check')
? 'start Checking formatting...\nsuccess No supported files to check.\n'
: modeArgs.includes('--list-different')
? ''
: 'start Formatting...\nsuccess No supported files to format.\n';
expect(result.stdout).toBe(expectedStdout);
expect(result.stderr).toBe('');
}
});
Expand All @@ -77,7 +78,7 @@ test('supports -u as an alias for --ignore-unknown', () => {
const result = runFmt(['-u', 'notes.unknown']);

expect(result.status).toBe(0);
expect(result.stdout).toBe('');
expect(result.stdout).toBe('start Formatting...\nsuccess No supported files to format.\n');
expect(result.stderr).toBe('');
});

Expand All @@ -95,6 +96,6 @@ test('does not treat unsupported files as unmatched patterns', () => {
const result = runFmt(['--no-error-on-unmatched-pattern', 'notes.unknown']);

expect(result.status).toBe(2);
expect(result.stdout).toBe('');
expect(result.stdout).toBe('start Formatting...\n');
expect(result.stderr).toContain('No supported files matched "notes.unknown"');
});