amlinger / homebridge-telldus-tdtool

A Homebridge plugin for Tellstick without Live, interfaced with the CLI tool tdtool.
21 stars 11 forks source link

replacing the endswith('Success') logic which doesnt seem to work #10

Closed kskaret closed 8 years ago

kskaret commented 8 years ago

I'm pretty sure I found the fault. There's something wrong with the String comparison in out.indexOf(). I've never done any node / js before, but here is a solution that worked for me!

amlinger commented 8 years ago

Nice catch! I believe the error stems from something as simple as a typo though, in fact.

return out.endsWith('Success') ? callback() : Promise.reject(out)

would have been working, I guess (assuming that you're running Node>=4, or Node 0.12 with harmony-flags). Babel does not transpile that either, so running it on Node 0.12 without harmony will require a polyfill to be dragged in, which seems a bit excessive. With that in mind, your solution seems to be best :)

Thanks!