From 07ca88fd1aab1856a39ac9e74bef5dfa2fec6b75 Mon Sep 17 00:00:00 2001 From: TrueBoxGuy Date: Sun, 17 Jun 2018 19:48:40 +0100 Subject: [PATCH 1/2] Added fs callback to remove node deprecation 0013 Added a callback to fs.unlink that calls the callback on error. This code follows the coding style of the rest of the code --- lib/tesseract.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tesseract.js b/lib/tesseract.js index 2f7e13c..e8a4a8c 100644 --- a/lib/tesseract.js +++ b/lib/tesseract.js @@ -97,7 +97,12 @@ var Tesseract = { var index = Tesseract.tmpFiles.indexOf(output); if (~index) Tesseract.tmpFiles.splice(index, 1); - fs.unlinkSync(files[0]); + fs.unlink(files[0], function(err) { + if (err) { + callback(err, null); + return; + } + }); callback(null, data) }); From d5ba3ddc09dcb41a57a12dac3ba8e582d54053d0 Mon Sep 17 00:00:00 2001 From: TrueBoxGuy Date: Sun, 17 Jun 2018 19:54:31 +0100 Subject: [PATCH 2/2] Indents Fixed indentation of added code. --- lib/tesseract.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tesseract.js b/lib/tesseract.js index e8a4a8c..4136eae 100644 --- a/lib/tesseract.js +++ b/lib/tesseract.js @@ -96,13 +96,13 @@ var Tesseract = { var index = Tesseract.tmpFiles.indexOf(output); if (~index) Tesseract.tmpFiles.splice(index, 1); - + fs.unlink(files[0], function(err) { - if (err) { + if (err) { callback(err, null); return; } - }); + }); callback(null, data) });