@@ -122,44 +122,62 @@ describe('postprocessOutput', () => {
122122 ) . toThrow ( 'Post-processor "My Formatter" failed to run: spawnSync my-formatter ENOENT' ) ;
123123 } ) ;
124124
125- it ( 'should throw ConfigError when the process exits with a non-zero status code' , ( ) => {
125+ it ( 'should warn when the process exits with a non-zero status code' , ( ) => {
126126 mockSync . mockReturnValue ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any ) ;
127+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
127128
128- expect ( ( ) =>
129- postprocessOutput (
130- { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
131- noopPostProcessors ,
132- '' ,
133- ) ,
134- ) . toThrow ( ConfigError ) ;
135- } ) ;
136-
137- it ( 'should include exit code in error message' , ( ) => {
138- mockSync . mockReturnValue ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any ) ;
129+ postprocessOutput (
130+ { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
131+ noopPostProcessors ,
132+ '' ,
133+ ) ;
139134
140- expect ( ( ) =>
141- postprocessOutput (
142- { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'prettier' } ] } ,
143- noopPostProcessors ,
144- '' ,
145- ) ,
146- ) . toThrow ( 'Post-processor "prettier" exited with code 1' ) ;
135+ expect ( warnSpy ) . toHaveBeenCalledWith (
136+ expect . stringContaining ( 'Post-processor "prettier" exited with code 1' ) ,
137+ ) ;
138+ warnSpy . mockRestore ( ) ;
147139 } ) ;
148140
149- it ( 'should include stderr output in error message when process fails ' , ( ) => {
141+ it ( 'should include stderr in warning when process exits with non-zero status ' , ( ) => {
150142 mockSync . mockReturnValue ( {
151143 error : undefined ,
152144 status : 2 ,
153145 stderr : Buffer . from ( 'error: file not found' ) ,
154146 } as any ) ;
147+ const warnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
155148
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' ) ;
149+ postprocessOutput (
150+ { ...baseConfig , postProcess : [ { args : [ '{{path}}' ] , command : 'biome' } ] } ,
151+ noopPostProcessors ,
152+ '' ,
153+ ) ;
154+
155+ expect ( warnSpy ) . toHaveBeenCalledTimes ( 1 ) ;
156+ const warnArg = warnSpy . mock . calls [ 0 ] ! [ 0 ] as string ;
157+ expect ( warnArg ) . toContain ( 'Post-processor "biome" exited with code 2:' ) ;
158+ expect ( warnArg ) . toContain ( 'error: file not found' ) ;
159+ warnSpy . mockRestore ( ) ;
160+ } ) ;
161+
162+ it ( 'should continue processing after a non-zero exit code' , ( ) => {
163+ mockSync
164+ . mockReturnValueOnce ( { error : undefined , status : 1 , stderr : Buffer . from ( '' ) } as any )
165+ . mockReturnValueOnce ( { error : undefined , status : 0 } as any ) ;
166+ vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
167+
168+ postprocessOutput (
169+ {
170+ ...baseConfig ,
171+ postProcess : [
172+ { args : [ '{{path}}' ] , command : 'first' } ,
173+ { args : [ '{{path}}' ] , command : 'second' } ,
174+ ] ,
175+ } ,
176+ noopPostProcessors ,
177+ '' ,
178+ ) ;
179+
180+ expect ( mockSync ) . toHaveBeenCalledTimes ( 2 ) ;
163181 } ) ;
164182
165183 it ( 'should not throw when the process is killed by a signal (null status)' , ( ) => {
0 commit comments