Skip to content

Commit 9066017

Browse files
committed
feat: don't override screenshots if not needed
this change helps git track file changes properly Signed-off-by: Jakub Freisler <[email protected]>
1 parent 683bf8a commit 9066017

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/plugins.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@ export const initPlugin = (
180180
imgDiff,
181181
maxDiffThreshold: cfg.maxDiffThreshold,
182182
};
183+
} else {
184+
// don't overwrite file if it's the same (imgDiff < cfg.maxDiffThreshold && !isImgSizeDifferent)
185+
fs.unlinkSync(cfg.imgNew);
183186
}
184-
185-
fs.unlinkSync(cfg.imgOld);
186187
} else {
187188
// there is no "old screenshot" or screenshots should be immediately updated
188189
imgDiff = 0;
190+
moveFile.sync(cfg.imgNew, cfg.imgOld);
189191
}
190192

191-
moveFile.sync(cfg.imgNew, cfg.imgOld);
192-
193193
if (typeof imgDiff !== "undefined") {
194194
const roundedImgDiff = Math.ceil(imgDiff * 1000) / 1000;
195195
return {

0 commit comments

Comments
 (0)