@@ -374,26 +374,28 @@ async function getGitChanges() {
374374 */
375375export function getChangesSinceLastFileVersion (
376376 lastFileVersion : Record < string , string >
377- ) {
377+ ) : Record < string , string > {
378378 const changes = Object . entries ( lastFileVersion )
379- . map ( ( [ filePath , file ] ) => {
379+ . map ( ( [ filePath , lastContents ] ) => {
380380 const fullFilePath = path . join ( getProjectRoot ( ) , filePath )
381381 try {
382382 const currentContent = fs . readFileSync ( fullFilePath , 'utf8' )
383- if ( currentContent === file ) {
383+ if ( currentContent === lastContents ) {
384384 return [ filePath , null ] as const
385385 }
386- return [ filePath , createPatch ( filePath , file , currentContent ) ] as const
386+ return [
387+ filePath ,
388+ createPatch ( filePath , lastContents , currentContent ) ,
389+ ] as const
387390 } catch ( error ) {
388- logger . error (
389- {
390- errorMessage :
391- error instanceof Error ? error . message : String ( error ) ,
392- errorStack : error instanceof Error ? error . stack : undefined ,
393- filePath : fullFilePath ,
394- } ,
395- 'Error reading file for changes comparison'
396- )
391+ if (
392+ error instanceof Object &&
393+ 'code' in error &&
394+ error . code === 'ENOENT'
395+ ) {
396+ return [ filePath , createPatch ( filePath , lastContents , '' ) ]
397+ }
398+ logger . error ( { error } , 'Error reading file while getting file changes' )
397399 return [ filePath , null ] as const
398400 }
399401 } )
0 commit comments