Skip to content

Commit caae97f

Browse files
Merge pull request #13 from ssddi456/main
add babel runtime as a dependencies, optimize for complex folder structure
2 parents 6d4fa11 + d92a9c3 commit caae97f

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"homepage": "https://github.com/uktrade/cypress-image-diff#readme",
3131
"dependencies": {
32+
"@babel/runtime": "^7.12.5",
3233
"cypress": "^5.3.0",
3334
"fs-extra": "^9.0.1",
3435
"handlebars": "^4.7.6",

src/plugin.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const generateReport = (instance = '') => {
3232
const copyScreenshot = args => {
3333
// If baseline does not exist, copy comparison image to baseline folder
3434
if (!fs.existsSync(paths.image.baseline(args.testName))) {
35-
fs.copyFileSync(paths.image.comparison(args.testName), paths.image.baseline(args.testName))
35+
fs.copySync(paths.image.comparison(args.testName), paths.image.baseline(args.testName))
3636
}
3737

3838
return true
@@ -71,6 +71,7 @@ async function compareSnapshotsPlugin(args) {
7171
const testFailed = percentage > args.testThreshold
7272

7373
if (testFailed) {
74+
fs.ensureFileSync(paths.image.diff(args.testName))
7475
diff.pack().pipe(fs.createWriteStream(paths.image.diff(args.testName)))
7576
}
7677

src/utils.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ const setFilePermission = (dir, permission) => {
2828
}
2929

3030
const renameAndMoveFile = (originalFilePath, newFilePath) => {
31-
const readStream = fs.createReadStream(originalFilePath)
32-
const writeStream = fs.createWriteStream(newFilePath)
33-
readStream.pipe(writeStream)
34-
// eslint-disable-next-line func-names
35-
readStream.on('end', function() {
36-
fs.unlinkSync(originalFilePath)
37-
})
31+
fs.copySync(originalFilePath, newFilePath);
3832
}
3933

4034
const parseImage = async image => {

0 commit comments

Comments
 (0)