Closed oksas closed 7 years ago
O silly me, didn't see that you did actually add unit tests. I will look into the failing test here then and fix that.
Edit: Oh hah looks like the test is meant to fail
At first glance, this looks good. I'll pull down the changes later, and take it for a spin. Thanks for submitting this!
Sounds great, thanks dude!
Running ./bin/thumb
without any arguments throws this error:
(node:28912) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: options.logger is not a function
Other than that, works great!
Hmm ok, glad you tested the CLI because I clearly did not. I'll look into it this afternoon and refine. Thanks man!
It should be all good to go now. I ran my usual tests for ensuring the module works still with both callbacks and Promises, and the command line interface also seems to work without issue. Let me know how it looks!
Very good, thanks ✨
This is my stab at implementing Promises so that this module supports both Node-style callbacks and Promises. Here's a rundown of the changes:
es6
env added to eslint config, otherwise eslint would complain thatPromise
was not defined. If you are opposed to this, another option would be to addPromise
to theglobals
section in the eslint config.thumb
method returns anew Promise
, wraps everything inside that Promise, and the Promise'sresolve
andreject
get passed down the chain so that wheneverdone
/callback
are used,resolve
andreject
are in scope so they can be used instead if the user is using Promises instead of a callback.err
passed to the callback (or toreject
) is now an actualError
object instead of just a string. I'm not super experienced handling errors but this seemed like a good way to do it based on the information I could find (like from here).Let me know how that looks! Definitely open to feedback here, and I'm not 100% about everything. I think this might be a good stage to add some simple tests to the module, to always ensure both callbacks and Promises work, reject with errors at the right time with insufficient or invalid input, etc. I have a small ugly script I have been using to test this stuff myself but it might be worth adding some tests to the module itself.
Closes #11