File tree 2 files changed +21
-4
lines changed
2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -398,7 +398,6 @@ function REPLServer(prompt,
398
398
self . on ( 'line' , function ( cmd ) {
399
399
debug ( 'line %j' , cmd ) ;
400
400
sawSIGINT = false ;
401
- var skipCatchall = false ;
402
401
403
402
// leading whitespaces in template literals should not be trimmed.
404
403
if ( self . _inTemplateLiteral ) {
@@ -417,11 +416,12 @@ function REPLServer(prompt,
417
416
return ;
418
417
} else if ( ! self . bufferedCommand ) {
419
418
self . outputStream . write ( 'Invalid REPL keyword\n' ) ;
420
- skipCatchall = true ;
419
+ finish ( null ) ;
420
+ return ;
421
421
}
422
422
}
423
423
424
- if ( ! skipCatchall && ( cmd || ( ! cmd && self . bufferedCommand ) ) ) {
424
+ if ( cmd || self . bufferedCommand ) {
425
425
var evalCmd = self . bufferedCommand + cmd ;
426
426
if ( / ^ \s * \{ / . test ( evalCmd ) && / \} \s * $ / . test ( evalCmd ) ) {
427
427
// It's confusing for `{ a : 1 }` to be interpreted as a block
@@ -1022,7 +1022,7 @@ REPLServer.prototype.memory = function memory(cmd) {
1022
1022
// self.lines.level.length === 0
1023
1023
// TODO? keep a log of level so that any syntax breaking lines can
1024
1024
// be cleared on .break and in the case of a syntax error?
1025
- // TODO? if a log was kept, then I could clear the bufferedComand and
1025
+ // TODO? if a log was kept, then I could clear the bufferedCommand and
1026
1026
// eval these lines and throw the syntax error
1027
1027
} else {
1028
1028
self . lines . level = [ ] ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ require ( '../common' ) ;
3
+ const repl = require ( 'repl' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ var replserver = new repl . REPLServer ( ) ;
7
+
8
+ replserver . _inTemplateLiteral = true ;
9
+
10
+ // `null` gets treated like an empty string. (Should it? You have to do some
11
+ // strange business to get it into the REPL. Maybe it should really throw?)
12
+
13
+ assert . doesNotThrow ( ( ) => {
14
+ replserver . emit ( 'line' , null ) ;
15
+ } ) ;
16
+
17
+ replserver . emit ( 'line' , '.exit' ) ;
You can’t perform that action at this time.
0 commit comments