repl: fix crashes when buffering command
authorMaciej Małecki <maciej.malecki@notimplemented.org>
Tue, 3 Jul 2012 02:13:24 +0000 (04:13 +0200)
committerNathan Rajlich <nathan@tootallnate.net>
Wed, 4 Jul 2012 18:22:10 +0000 (11:22 -0700)
commit6a11f3edf429d614fd35a1cbac8b734d8a7e0797
treeb9c2dbd96194b03a8763aed9d364055b85473486
parent4fbe7a5fabbdcf9877fd1aa2b9e8c5ef40bd1306
repl: fix crashes when buffering command

Wrong order of operands was causing problems while trying to use command
buffering:

    > {
    ...   a: 3,
    ...

    repl.js:284
            if (cmd.trim().match(/^npm /) && !self.bufferedCommand) {
                    ^
    TypeError: Cannot call method 'trim' of undefined
        at finish (repl.js:284:17)
        at REPLServer.self.eval (repl.js:118:5)
        at rli.on.e (repl.js:260:20)
        at REPLServer.self.eval (repl.js:118:5)
        at Interface.<anonymous> (repl.js:250:12)
        at Interface.EventEmitter.emit (events.js:88:17)
        at Interface._onLine (readline.js:183:10)
        at Interface._line (readline.js:502:8)
        at Interface._ttyWrite (readline.js:720:14)
        at ReadStream.<anonymous> (readline.js:105:12)

Test included.

Closes #3515.
Closes #3517.
Closes #3621.
lib/repl.js
test/simple/test-repl.js