From 27113e4e7a3b6693fe0fb27fe3a2ffc42b24b02d Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 29 Aug 2020 10:37:03 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Store=20diff=20files=20from=20pi?= =?UTF-8?q?xelMatcher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/matchImages.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/matchImages.ts b/src/utils/matchImages.ts index 690d782..b654437 100644 --- a/src/utils/matchImages.ts +++ b/src/utils/matchImages.ts @@ -14,9 +14,14 @@ export const matchImages = (img1Buff: Buffer, img2Buff: Buffer) => { threshold: 0.3, }); - fs.writeFileSync( - path.resolve(process.cwd(), "diff", `${out}.png`), - diff.data - ); + if (process.env.NODE_ENV === "development") { + const diffFilesPath = path.resolve(process.cwd(), "diff"); + if (!fs.existsSync(diffFilesPath)) fs.mkdirSync(diffFilesPath); + fs.writeFileSync( + path.resolve(diffFilesPath, `${out}.png`), + PNG.sync.write(diff) + ); + } + return out; };