From 3bca6e5c31850312661f86ecb97be77b919e687f Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sun, 23 Jun 2024 14:02:31 +0700 Subject: [PATCH] fix(patches/tesseract.js): check if original file exists before using new path --- patches/tesseract.js@5.1.0.patch | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/patches/tesseract.js@5.1.0.patch b/patches/tesseract.js@5.1.0.patch index c217d0f..93ecfc3 100644 --- a/patches/tesseract.js@5.1.0.patch +++ b/patches/tesseract.js@5.1.0.patch @@ -1,11 +1,19 @@ diff --git a/src/worker/node/defaultOptions.js b/src/worker/node/defaultOptions.js -index 053c1e3e3b561b2e5b5e3609e9c6b509b1661f11..d4fe84893786d340de3527bcf7f090e1006c0f09 100644 +index 053c1e3e3b561b2e5b5e3609e9c6b509b1661f11..407242f5576f8d888644ab28ff169599a79bf4dd 100644 --- a/src/worker/node/defaultOptions.js +++ b/src/worker/node/defaultOptions.js -@@ -6,5 +6,5 @@ const defaultOptions = require('../../constants/defaultOptions'); +@@ -1,10 +1,13 @@ + const path = require('path'); ++const fs = require('fs'); + const defaultOptions = require('../../constants/defaultOptions'); + ++const defaultPath = path.join(import.meta.dir, '..', '..', 'worker-script', 'node', 'index.js') ++ + /* + * Default options for node worker */ module.exports = { ...defaultOptions, - workerPath: path.join(__dirname, '..', '..', 'worker-script', 'node', 'index.js'), -+ workerPath: path.join(import.meta.dir, 'tesseract.js', 'src', 'worker-script', 'node', 'index.js'), ++ workerPath: fs.existsSync(defaultPath) ? defaultPath : path.join(import.meta.dir, 'tesseract.js', 'src', 'worker-script', 'node', 'index.js'), };