File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -30,15 +30,20 @@ const initGetScreenshotPathTask: () => Cypress.Tasks = () => ({
3030 } ,
3131} ) ;
3232
33+ const unlinkSyncSafe = ( path : string ) =>
34+ fs . existsSync ( path ) && fs . unlinkSync ( path ) ;
35+ const moveSyncSafe = ( pathFrom : string , pathTo : string ) =>
36+ fs . existsSync ( pathFrom ) && moveFile . sync ( pathFrom , pathTo ) ;
37+
3338const initApproveImageTask : ( ) => Cypress . Tasks = ( ) => ( {
3439 [ TASK . approveImage ] ( { img } ) {
3540 const oldImg = img . replace ( FILE_SUFFIX . actual , "" ) ;
36- if ( fs . existsSync ( oldImg ) ) fs . unlinkSync ( oldImg ) ;
41+ unlinkSyncSafe ( oldImg ) ;
3742
3843 const diffImg = img . replace ( FILE_SUFFIX . actual , FILE_SUFFIX . diff ) ;
39- if ( fs . existsSync ( diffImg ) ) fs . unlinkSync ( diffImg ) ;
44+ unlinkSyncSafe ( diffImg ) ;
4045
41- if ( fs . existsSync ( img ) ) moveFile . sync ( img , oldImg ) ;
46+ moveSyncSafe ( img , oldImg ) ;
4247
4348 return null ;
4449 } ,
You can’t perform that action at this time.
0 commit comments