@@ -122,42 +122,44 @@ describe('postprocessOutput', () => {
122122 ) . toThrow ( 'Post-processor "My Formatter" failed to run: spawnSync my-formatter ENOENT' ) ;
123123 } ) ;
124124
125- it ( 'should silently ignore non-zero exit codes' , ( ) => {
126- mockSync . mockReturnValue ( {
127- error : undefined ,
128- status : 1 ,
129- stderr : Buffer . from ( 'some error' ) ,
130- } as any ) ;
131- const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
132-
133- postprocessOutput (
134- { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
135- noopPostProcessors ,
136- '' ,
137- ) ;
125+ it ( 'should throw ConfigError when the process exits with a non-zero status code' , ( ) => {
126+ mockSync . mockReturnValue ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any ) ;
138127
139- expect ( warnSpy ) . not . toHaveBeenCalled ( ) ;
140- warnSpy . mockRestore ( ) ;
128+ expect ( ( ) =>
129+ postprocessOutput (
130+ { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
131+ noopPostProcessors ,
132+ '' ,
133+ ) ,
134+ ) . toThrow ( ConfigError ) ;
141135 } ) ;
142136
143- it ( 'should continue processing after a non-zero exit code' , ( ) => {
144- mockSync
145- . mockReturnValueOnce ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any )
146- . mockReturnValueOnce ( { error : undefined , status : 0 } as any ) ;
137+ it ( 'should include exit code in error message' , ( ) => {
138+ mockSync . mockReturnValue ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any ) ;
147139
148- postprocessOutput (
149- {
150- ...baseConfig ,
151- postProcess : [
152- { args : [ '{{path}}' ] , command : 'first' } ,
153- { args : [ '{{path}}' ] , command : 'second' } ,
154- ] ,
155- } ,
156- noopPostProcessors ,
157- '' ,
158- ) ;
140+ expect ( ( ) =>
141+ postprocessOutput (
142+ { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
143+ noopPostProcessors ,
144+ '' ,
145+ ) ,
146+ ) . toThrow ( 'Post-processor "prettier" exited with code 1' ) ;
147+ } ) ;
159148
160- expect ( mockSync ) . toHaveBeenCalledTimes ( 2 ) ;
149+ it ( 'should include stderr output in error message when process fails' , ( ) => {
150+ mockSync . mockReturnValue ( {
151+ error : undefined ,
152+ status : 2 ,
153+ stderr : Buffer . from ( 'error: file not found' ) ,
154+ } as any ) ;
155+
156+ expect ( ( ) =>
157+ postprocessOutput (
158+ { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'biome' } ] } ,
159+ noopPostProcessors ,
160+ '' ,
161+ ) ,
162+ ) . toThrow ( 'Post-processor "biome" exited with code 2:\nerror: file not found' ) ;
161163 } ) ;
162164
163165 it ( 'should not throw when the process is killed by a signal (null status)' , ( ) => {
0 commit comments