dmtrKovalenko/odiff

Undocumented fourth arg to compare()

StructByLightning opened this issue · 1 comments

For the npm package, the fourth options arg is required for compare() but isn't documented. When calling compare with this code:

const { match, reason } = await compare("path/to/first/image.png",
    "path/to/second/image.png",
    "path/to/diff.png");

I get this error:

(node:87053) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '__binaryPath' of undefined
    at /home/raven/Documents/jobs/deviate-labs/repos/Deviate-Site-Tester/node_modules/odiff-bin/odiff.js:86:32
    at new Promise (<anonymous>)
    at compare (/home/raven/Documents/jobs/deviate-labs/repos/Deviate-Site-Tester/node_modules/odiff-bin/odiff.js:83:10)
    at tmp (file:///home/raven/Documents/jobs/deviate-labs/repos/Deviate-Site-Tester/test.js:3:35)
    at file:///home/raven/Documents/jobs/deviate-labs/repos/Deviate-Site-Tester/test.js:7:1
    at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
    at async Loader.import (internal/modules/esm/loader.js:166:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:87053) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:87053) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The fourth argument should be documented or made optional. Note that the fourth arg can be "" and it works fine. This code doesn't error out:

const { match, reason } = await compare("path/to/first/image.png",
    "path/to/second/image.png",
    "path/to/diff.png",
    "");

Released in 2.3.1