From d65f48ac9d828a3f79014fdd7637d254bb530395 Mon Sep 17 00:00:00 2001 From: kaffarell Date: Mon, 14 Aug 2023 18:05:03 +0200 Subject: [PATCH] fix #3: error out only when stdout is empty When executing tesseract, sometimes we get the correct output on stdout and an error on stderr, in that case we simply use the stdout and discard the error. Bump to version 0.3.8. --- manifest.json | 2 +- package.json | 2 +- src/main.ts | 3 ++- versions.json | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 1185d3a..ec89d55 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "image-ocr", "name": "Image OCR", - "version": "0.3.7", + "version": "0.3.8", "minAppVersion": "0.15.0", "description": "Runs OCR on images and copies content in image caption.", "author": "kaffarell", diff --git a/package.json b/package.json index 5ca3817..c820225 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "image-ocr", - "version": "0.3.7", + "version": "0.3.8", "description": "Runs ocr on pasted images and posts result in details box. This allows to search in images.", "main": "dist/main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index 6315a74..23fae22 100644 --- a/src/main.ts +++ b/src/main.ts @@ -174,7 +174,8 @@ export default class TesseractOcrPlugin extends Plugin { execution.on('close', () => { if (this.settings.debug == true) console.log('tesseract output: ' + stdout.join('')); if (this.settings.debug == true) console.log('tesseract output: ' + error.join('')); - if (error.length) reject(error.join('')); + // if we don't get any output, reject + if (stdout.join('').length == 0) reject(error.join('')); else resolve(stdout.join('')); }); diff --git a/versions.json b/versions.json index b81aca8..afc5ce5 100644 --- a/versions.json +++ b/versions.json @@ -8,5 +8,6 @@ "0.3.4": "0.15.0", "0.3.5": "0.15.0", "0.3.6": "0.15.0", - "0.3.7": "0.15.0" + "0.3.7": "0.15.0", + "0.3.8": "0.15.0" }