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
22 changes: 11 additions & 11 deletions packages/rstack/src/cli/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ ${color.cyan('Usage')}:
${color.yellow(' $ rs [command] [...options]')}

${color.cyan('Commands')}:
dev Run the app dev server
build Build the app for production
preview Preview the app production build
lib Build library
doc Serve or build docs
fmt Format code
lint Lint code
test Run tests
staged Run tasks on staged Git files
setup Install Git hooks
dev Run the app dev server
build Build the app for production
preview Preview the app production build
lib Build library
doc Serve or build docs
fmt, format Format code
lint Lint code
test Run tests
staged Run tasks on staged Git files
setup Install Git hooks

${color.dim(`For command-specific options, run:
$ rs <command> -h`)}
Expand Down Expand Up @@ -144,7 +144,7 @@ export async function setupCommands(): Promise<void> {
return;
}

if (command === 'fmt') {
if (command === 'fmt' || command === 'format') {
const { runFmtCLI } = await import(
/* rspackChunkName: 'fmt' */
'../fmt/cli.ts'
Expand Down
13 changes: 12 additions & 1 deletion packages/rstack/tests/cli/fmt/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,23 @@ test('displays fmt help without loading config', () => {
const fmt = runFmt(['--help']);

expect(topLevel.status).toBe(0);
expect(topLevel.stdout).toContain('fmt Format code');
expect(topLevel.stdout).toContain('fmt, format Format code');
expect(fmt.status).toBe(0);
expect(fmt.stdout).toContain('Usage:\n $ rs fmt [options] [files/globs...]');
expect(fmt.stderr).toBe('');
});

test('supports format as an alias for fmt', () => {
writeProjectFile('index.ts', 'const message="hello"');

const result = runCLI(['format', 'index.ts']);

expect(result.status).toBe(0);
expect(result.stdout).toBe('index.ts\n');
expect(result.stderr).toBe('');
expect(readProjectFile('index.ts')).toBe('const message = "hello";\n');
});

test('returns exit code 1 for invalid arguments', () => {
const result = runFmt(['--write', '--check']);

Expand Down
2 changes: 1 addition & 1 deletion packages/rstack/tests/cli/setup/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ afterEach(() => {
});

test('displays setup help', ({ execCli, expect }) => {
expect(execCli('--help', { cwd })).toContain('setup Install Git hooks');
expect(execCli('--help', { cwd })).toMatch(/setup\s+Install Git hooks/);

const output = execCli('setup --help', { cwd });

Expand Down