File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,16 +15,16 @@ ${color.cyan('Usage')}:
1515${ color . yellow ( ' $ rs [command] [...options]' ) }
1616
1717${ color . cyan ( 'Commands' ) } :
18- dev Run the app dev server
19- build Build the app for production
20- preview Preview the app production build
21- lib Build library
22- doc Serve or build docs
23- fmt Format code
24- lint Lint code
25- test Run tests
26- staged Run tasks on staged Git files
27- setup Install Git hooks
18+ dev Run the app dev server
19+ build Build the app for production
20+ preview Preview the app production build
21+ lib Build library
22+ doc Serve or build docs
23+ fmt, format Format code
24+ lint Lint code
25+ test Run tests
26+ staged Run tasks on staged Git files
27+ setup Install Git hooks
2828
2929${ color . dim ( `For command-specific options, run:
3030 $ rs <command> -h` ) }
@@ -144,7 +144,7 @@ export async function setupCommands(): Promise<void> {
144144 return ;
145145 }
146146
147- if ( command === 'fmt' ) {
147+ if ( command === 'fmt' || command === 'format' ) {
148148 const { runFmtCLI } = await import (
149149 /* rspackChunkName: 'fmt' */
150150 '../fmt/cli.ts'
Original file line number Diff line number Diff line change @@ -45,12 +45,23 @@ test('displays fmt help without loading config', () => {
4545 const fmt = runFmt ( [ '--help' ] ) ;
4646
4747 expect ( topLevel . status ) . toBe ( 0 ) ;
48- expect ( topLevel . stdout ) . toContain ( 'fmt Format code' ) ;
48+ expect ( topLevel . stdout ) . toContain ( 'fmt, format Format code' ) ;
4949 expect ( fmt . status ) . toBe ( 0 ) ;
5050 expect ( fmt . stdout ) . toContain ( 'Usage:\n $ rs fmt [options] [files/globs...]' ) ;
5151 expect ( fmt . stderr ) . toBe ( '' ) ;
5252} ) ;
5353
54+ test ( 'supports format as an alias for fmt' , ( ) => {
55+ writeProjectFile ( 'index.ts' , 'const message="hello"' ) ;
56+
57+ const result = runCLI ( [ 'format' , 'index.ts' ] ) ;
58+
59+ expect ( result . status ) . toBe ( 0 ) ;
60+ expect ( result . stdout ) . toBe ( 'index.ts\n' ) ;
61+ expect ( result . stderr ) . toBe ( '' ) ;
62+ expect ( readProjectFile ( 'index.ts' ) ) . toBe ( 'const message = "hello";\n' ) ;
63+ } ) ;
64+
5465test ( 'returns exit code 1 for invalid arguments' , ( ) => {
5566 const result = runFmt ( [ '--write' , '--check' ] ) ;
5667
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ afterEach(() => {
4343} ) ;
4444
4545test ( 'displays setup help' , ( { execCli, expect } ) => {
46- expect ( execCli ( '--help' , { cwd } ) ) . toContain ( ' setup Install Git hooks' ) ;
46+ expect ( execCli ( '--help' , { cwd } ) ) . toMatch ( / s e t u p \s + I n s t a l l G i t h o o k s / ) ;
4747
4848 const output = execCli ( 'setup --help' , { cwd } ) ;
4949
You can’t perform that action at this time.
0 commit comments