guo-yu / btc

a command-line bitcoin price board for geeks
MIT License
389 stars 73 forks source link

crashes on keypress #1

Open ledbettj opened 10 years ago

ledbettj commented 10 years ago

crashes on keypress for certain non-alphanumeric keys, for example .,?.

/usr/lib/node_modules/btc/libs/cli.js:125
        if (key.name == 'return') {
           ^
TypeError: Cannot read property 'name' of undefined
    at List.module.exports (/usr/lib/node_modules/btc/libs/cli.js:125:16)
    at List.EventEmitter.emit (events.js:99:17)
    at List.onkeypress (/usr/lib/node_modules/btc/node_modules/term-list/index.js:54:8)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at emitKey (/usr/lib/node_modules/btc/node_modules/term-list/node_modules/keypress/index.js:406:12)
    at ReadStream.onData (/usr/lib/node_modules/btc/node_modules/term-list/node_modules/keypress/index.js:48:14)
    at ReadStream.EventEmitter.emit (events.js:126:20)
    at TTY.onread (net.js:397:14)

Edit:

based on the keypress examples it looks like it's expected to check that key is truthy prior to checking any properties. (if (key && key.name == 'return') { ... })

vincemtnz commented 10 years ago

This is a bug in node-term-list. Fixing it here will still cause btc to crash, since there's a switch in the default onkeypress behaviour in node-term-list. I've reported a bug over there: visionmedia/node-term-list#4 and submitted a pull request, which should fix the problem (once the dependency has been updated).

ledbettj commented 10 years ago

:+1:

vincemtnz commented 10 years ago

node-term-list has been updated to 0.2.1 now, which fixes this bug.

guo-yu commented 10 years ago

thank you @eyko , nice work!