@@ -162,10 +162,6 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
162162 return { status : "identical" , content : existingFileContent } ;
163163 }
164164
165- // Prompt for conflict resolution
166- const tempFilePath = path . join ( "/tmp" , `temp_${ path . basename ( config . path ) } ` ) ;
167- await fs . writeFile ( tempFilePath , newContent || "" ) ;
168-
169165 let userChoice : Result | undefined ;
170166 while ( ! userChoice ) {
171167 const action = await expand ( {
@@ -194,7 +190,14 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
194190 case "overwrite_all" :
195191 globalConfig . overwriteAll = true ;
196192 return { status : "overwrite" , content : newContent } ;
197- case "diff" :
193+ case "diff" : {
194+ // Prompt for conflict resolution
195+ const tempFilePath = path . join (
196+ config . data ! . projectPath as string ,
197+ `.temp_${ path . basename ( config . path ) } ` ,
198+ ) ;
199+ await fs . writeFile ( tempFilePath , newContent || "" ) ;
200+
198201 if ( ! isTemplate && Buffer . isBuffer ( existingFileContent ) ) {
199202 const existingStats = await fs . stat ( config . path ) ;
200203 const newStats = await fs . stat ( tempFilePath ) ;
@@ -219,17 +222,18 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
219222 } else {
220223 await getDiff ( config . path , tempFilePath ) ;
221224 }
225+
226+ await fs . unlink ( tempFilePath ) . catch ( ( ) => {
227+ logger . warn ( `Failed to delete temporary file: ${ tempFilePath } ` ) ;
228+ } ) ;
222229 break ;
230+ }
223231 case "abort" :
224232 logger . error ( "Aborting process..." ) ;
225233 process . exit ( 1 ) ;
226234 }
227235 }
228236
229- await fs . unlink ( tempFilePath ) . catch ( ( ) => {
230- logger . warn ( `Failed to delete temporary file: ${ tempFilePath } ` ) ;
231- } ) ;
232-
233237 return userChoice ;
234238 }
235239 // If the file doesn't exist, create it
0 commit comments