It looks like the module still functions/does the thumbnail conversion, but the error TypeError: options.logger is not a function was being thrown whenever the module is trying to log something. It happens both here and further down the file here as well. This line appears to be where default properties get overridden by any user options, but its location in that if block means that if sibling else if blocks are executed, the logger is not on the options object unless the user explicitly provides one.
The two options for fixing this that came to mind are:
pull the _.defaults on 154 line outside the if block and execute it unconditionally, before the source/dest checks, OR
change the logger usage in the else if blocks to be defaults.logger instead, but downside of this is that the user could supply a custom logger but an invalid source/dest, and the error would still go through the default logger instead of their custom one
I opted for the first because of the issue mentioned in the second, but let me know what you think! The issue on line 127 was fixed simply by changing options.logger to settings.logger since options in that area seems to be referencing something separate.
Hahah no worries. It seems like it might be worthwhile to add even some basic unit tests to the module at some point, to catch stuff like this more easily.
It looks like the module still functions/does the thumbnail conversion, but the error
TypeError: options.logger is not a function
was being thrown whenever the module is trying to log something. It happens both here and further down the file here as well. This line appears to be where default properties get overridden by any user options, but its location in thatif
block means that if siblingelse if
blocks are executed, the logger is not on theoptions
object unless the user explicitly provides one.The two options for fixing this that came to mind are:
_.defaults
on 154 line outside the if block and execute it unconditionally, before the source/dest checks, ORelse if
blocks to bedefaults.logger
instead, but downside of this is that the user could supply a custom logger but an invalid source/dest, and the error would still go through the default logger instead of their custom oneI opted for the first because of the issue mentioned in the second, but let me know what you think! The issue on line 127 was fixed simply by changing
options.logger
tosettings.logger
sinceoptions
in that area seems to be referencing something separate.