@@ -216,6 +216,11 @@ export const build = async ({
216
216
spinner . text = 'Deleting pre-existing modified preview app folder' ;
217
217
await fs . promises . rm ( modifiedPreviewAppPath , { recursive : true } ) ;
218
218
}
219
+ const builtPreviewAppPath = path . join ( process . cwd ( ) , '.react-email' ) ;
220
+ if ( fs . existsSync ( builtPreviewAppPath ) ) {
221
+ spinner . text = 'Deleting pre-existing .react-email folder' ;
222
+ await fs . promises . rm ( builtPreviewAppPath , { recursive : true } ) ;
223
+ }
219
224
220
225
spinner . text = 'Copying preview app from CLI to modify it' ;
221
226
await fs . promises . cp ( previewServerLocation , modifiedPreviewAppPath , {
@@ -259,24 +264,25 @@ export const build = async ({
259
264
} ) ;
260
265
await buildPreviewApp ( modifiedPreviewAppPath ) ;
261
266
267
+ await fs . promises . mkdir ( builtPreviewAppPath ) ;
262
268
await fs . promises . cp (
263
269
path . join ( modifiedPreviewAppPath , '.next' ) ,
264
- path . join ( process . cwd ( ) , '.next' ) ,
270
+ path . join ( builtPreviewAppPath , '.next' ) ,
265
271
{
266
272
recursive : true ,
267
273
} ,
268
274
) ;
269
- // await fs.promises.cp(
270
- // path.join(modifiedPreviewAppPath, 'public'),
271
- // path.join(builtPreviewAppPath, 'public'),
272
- // {
273
- // recursive: true,
274
- // },
275
- // );
276
-
277
- // await fs.promises.rm(modifiedPreviewAppPath, {
278
- // recursive: true,
279
- // });
275
+ await fs . promises . cp (
276
+ path . join ( modifiedPreviewAppPath , 'public' ) ,
277
+ path . join ( builtPreviewAppPath , 'public' ) ,
278
+ {
279
+ recursive : true ,
280
+ } ,
281
+ ) ;
282
+
283
+ await fs . promises . rm ( modifiedPreviewAppPath , {
284
+ recursive : true ,
285
+ } ) ;
280
286
} catch ( error ) {
281
287
console . log ( error ) ;
282
288
process . exit ( 1 ) ;
0 commit comments