@@ -30,6 +30,8 @@ interface ParsedFmtCLIArgs {
3030}
3131
3232type RunFmtCLIOptions = {
33+ /** Command shown to fix formatting issues found in check mode. */
34+ fixCommand ?: string ;
3335 /** Rstack config already loaded by the lint phase of `rs check`. */
3436 loadedConfig ?: LoadedRstackConfig ;
3537} ;
@@ -206,6 +208,7 @@ const logFmtResult = (
206208 cwd : string ,
207209 processedFileCount : number ,
208210 durationSeconds : number ,
211+ fixCommand ?: string ,
209212) : void => {
210213 let writtenCount = 0 ;
211214 let differentCount = 0 ;
@@ -248,10 +251,10 @@ const logFmtResult = (
248251 if ( differentCount > 0 ) {
249252 const differentFiles = formatFileCount ( differentCount , true ) ;
250253 const processedFiles = formatFileCount ( processedFileCount ) ;
251- const fmtCommand = color . cyan ( 'rs fmt' ) ;
252- logger . error (
253- `Formatting issues found in ${ differentFiles } . Run ${ fmtCommand } to fix.`,
254- ) ;
254+ const fixHint = fixCommand
255+ ? `Run ${ color . cyan ( fixCommand ) } to fix.`
256+ : `Rerun this command without ${ color . cyan ( '--check' ) } to fix.`;
257+ logger . error ( `Formatting issues found in ${ differentFiles } . ${ fixHint } ` ) ;
255258 logger . info ( `Checked ${ processedFiles } in ${ prettyTime ( durationSeconds ) } .` ) ;
256259 } else if ( result . exitCode === 0 ) {
257260 logger . success (
@@ -276,7 +279,7 @@ const loadFmtConfig = async (
276279
277280const runFmtCLI = async (
278281 args : string [ ] ,
279- { loadedConfig } : RunFmtCLIOptions = { } ,
282+ { fixCommand , loadedConfig } : RunFmtCLIOptions = { } ,
280283) : Promise < void > => {
281284 const cwd = process . cwd ( ) ;
282285 const startTime = performance . now ( ) ;
@@ -413,7 +416,14 @@ const runFmtCLI = async (
413416 }
414417
415418 const durationSeconds = ( performance . now ( ) - startTime ) / 1000 ;
416- logFmtResult ( result , mode , cwd , result . processedFileCount , durationSeconds ) ;
419+ logFmtResult (
420+ result ,
421+ mode ,
422+ cwd ,
423+ result . processedFileCount ,
424+ durationSeconds ,
425+ fixCommand ,
426+ ) ;
417427 process . exitCode = result . exitCode ;
418428 } catch ( error ) {
419429 logger . error ( error ) ;
0 commit comments