File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,19 @@ export const build = async (options: BuildOptions): Promise<BuildResult> => {
108108 // Create the directory if it doesn't exist
109109 await fs . mkdir ( dirName , { recursive : true } ) ;
110110
111- // Write the file
112- await fs . writeFile ( fullPath , result , "utf8" ) ;
111+ // Only write the file if content has changed
112+ let shouldWrite = true ;
113+ try {
114+ const existingContent = await fs . readFile ( fullPath , "utf8" ) ;
115+ shouldWrite = existingContent !== result ;
116+ } catch {
117+ // File doesn't exist or can't be read, so we should write it
118+ shouldWrite = true ;
119+ }
120+
121+ if ( shouldWrite ) {
122+ await fs . writeFile ( fullPath , result , "utf8" ) ;
123+ }
113124
114125 // Record successful file write
115126 await fs . stat ( fullPath ) ;
You can’t perform that action at this time.
0 commit comments