config-leaf icon indicating copy to clipboard operation
config-leaf copied to clipboard

rl.history is undefined

Open benthepoet opened this issue 9 years ago • 4 comments

I'm using Node 4.4.5. When trying to encrypt or decrypt Node crashes because it's trying to call slice on rl.history which hasn't been defined yet.

C:\Users\benhanna\Git\project\node_modules\config-leaf\index.js:34
        rl.history = rl.history.slice(1);
                               ^

TypeError: Cannot read property 'slice' of undefined
    at C:\Users\benhanna\Git\project\node_modules\config-leaf\index.js:34:32
    at Interface._onLine (readline.js:209:5)
    at Interface.<anonymous> (readline.js:341:12)
    at Array.forEach (native)
    at Interface._normalWrite (readline.js:340:11)
    at Socket.ondata (readline.js:87:10)
    at emitOne (events.js:82:20)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)

benthepoet avatar Jun 01 '16 17:06 benthepoet

hey @benthepoet, can you update the test to cover your issue? tests run fine for me on v4.4.5,

jed avatar Jun 01 '16 20:06 jed

Well it's the same commands in the test file that are failing for me. I'm using Windows 10 with Git Bash as my terminal. When you use Git Bash it blows up with the error above. However, using decrypt or encrypt in Command Prompt works successfully. Should probably just put in a safety to initialize rl.history to an empty string if it's undefined.

benthepoet avatar Jun 01 '16 20:06 benthepoet

cool. can you tee up a PR with the change you need?

jed avatar Jun 01 '16 20:06 jed

Yeah, I'll send one up when I get a chance.

benthepoet avatar Jun 01 '16 20:06 benthepoet