fix(patches/tesseract.js): check if original file exists before using new path

This commit is contained in:
PalmDevs
2024-06-23 14:02:31 +07:00
parent fa0159c3a8
commit 3bca6e5c31

View File

@@ -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'),
};