@@ -178,40 +178,42 @@ export function watchProject(
178178 } ) ;
179179
180180 if ( result . error ) {
181+ result . context . cleanup ( ) ;
181182 renderManager . onRenderError ( result . error ) ;
182183 return undefined ;
183- } else {
184- // record rendered hash
185- for ( const input of inputs . filter ( existsSync1 ) ) {
186- rendered . set ( input , md5Hash ( Deno . readTextFileSync ( input ) ) ) ;
187- }
188- renderManager . onRenderResult (
189- result ,
190- extensionDirs ,
191- resourceFiles ,
192- project ! ,
193- ) ;
194-
195- // Filter out supplmental files (e.g. files that were injected as supplements)
196- // to the render. Instead, we should return the first non-supplemental file.
197- // Example of supplemental file is a user rendering a post that appears in a listing
198- // - the listing will be added as a supplement since changes in the post may change the
199- // listing itself
200- const nonSupplementalFiles = result . files . filter (
201- ( renderResultFile ) => {
202- return ! renderResultFile . supplemental ;
203- } ,
204- ) ;
205-
206- return {
207- config : false ,
208- output : true ,
209- reloadTarget : ( nonSupplementalFiles . length &&
210- ! isPdfContent ( nonSupplementalFiles [ 0 ] . file ) )
211- ? join ( outputDir , nonSupplementalFiles [ 0 ] . file )
212- : undefined ,
213- } ;
214184 }
185+
186+ // record rendered hash
187+ for ( const input of inputs . filter ( existsSync1 ) ) {
188+ rendered . set ( input , md5Hash ( Deno . readTextFileSync ( input ) ) ) ;
189+ }
190+ renderManager . onRenderResult (
191+ result ,
192+ extensionDirs ,
193+ resourceFiles ,
194+ project ! ,
195+ ) ;
196+
197+ // Filter out supplmental files (e.g. files that were injected as supplements)
198+ // to the render. Instead, we should return the first non-supplemental file.
199+ // Example of supplemental file is a user rendering a post that appears in a listing
200+ // - the listing will be added as a supplement since changes in the post may change the
201+ // listing itself
202+ const nonSupplementalFiles = result . files . filter (
203+ ( renderResultFile ) => {
204+ return ! renderResultFile . supplemental ;
205+ } ,
206+ ) ;
207+ result . context . cleanup ( ) ;
208+
209+ return {
210+ config : false ,
211+ output : true ,
212+ reloadTarget : ( nonSupplementalFiles . length &&
213+ ! isPdfContent ( nonSupplementalFiles [ 0 ] . file ) )
214+ ? join ( outputDir , nonSupplementalFiles [ 0 ] . file )
215+ : undefined ,
216+ } ;
215217 } finally {
216218 services . cleanup ( ) ;
217219 }
0 commit comments