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