Skip to content

Commit

Permalink
v2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zapolnoch committed Apr 27, 2021
1 parent 87ec56f commit 622710b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {

rules: {
"prettier/prettier": "error",
"global-require": "off",
},
}
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const log = console.debug
function recognize(input, config = {}) {
const options = getOptions(config)
const binary = config.binary || "tesseract"
const inputOption =
typeof input === "string" && !input.match(/^https?:\/\//) ? `"${input}"` : "stdin"
const isSingleLocalFile = typeof input === "string" && !input.match(/^https?:\/\//)
const inputOption = isSingleLocalFile ? `"${input}"` : "stdin"
const command = [binary, inputOption, "stdout", ...options].join(" ")

if (config.debug) log("command", command)
Expand All @@ -27,6 +27,7 @@ function pipeInput(input, child) {
response.pipe(child.stdin)
})
}

if (Array.isArray(input)) input = Buffer.from(input.join("\n"), "utf-8")
child.stdin.write(input)
child.stdin.end()
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-tesseract-ocr",
"version": "2.1.0",
"version": "2.2.0",
"description": "A Node.js wrapper for the Tesseract OCR API",
"keywords": [
"ocr",
Expand Down Expand Up @@ -33,4 +33,4 @@
"rewire": "^5.0.0",
"tape": "^5.2.2"
}
}
}

0 comments on commit 622710b

Please sign in to comment.