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 = () => ({
30
30
} ,
31
31
} ) ;
32
32
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
+
33
38
const initApproveImageTask : ( ) => Cypress . Tasks = ( ) => ( {
34
39
[ TASK . approveImage ] ( { img } ) {
35
40
const oldImg = img . replace ( FILE_SUFFIX . actual , "" ) ;
36
- if ( fs . existsSync ( oldImg ) ) fs . unlinkSync ( oldImg ) ;
41
+ unlinkSyncSafe ( oldImg ) ;
37
42
38
43
const diffImg = img . replace ( FILE_SUFFIX . actual , FILE_SUFFIX . diff ) ;
39
- if ( fs . existsSync ( diffImg ) ) fs . unlinkSync ( diffImg ) ;
44
+ unlinkSyncSafe ( diffImg ) ;
40
45
41
- if ( fs . existsSync ( img ) ) moveFile . sync ( img , oldImg ) ;
46
+ moveSyncSafe ( img , oldImg ) ;
42
47
43
48
return null ;
44
49
} ,
You can’t perform that action at this time.
0 commit comments