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 @@ -396,7 +396,6 @@ function REPLServer(prompt,
396
396
self . on ( 'line' , function ( cmd ) {
397
397
debug ( 'line %j' , cmd ) ;
398
398
sawSIGINT = false ;
399
- var skipCatchall = false ;
400
399
401
400
// leading whitespaces in template literals should not be trimmed.
402
401
if ( self . _inTemplateLiteral ) {
@@ -415,11 +414,12 @@ function REPLServer(prompt,
415
414
return ;
416
415
} else if ( ! self . bufferedCommand ) {
417
416
self . outputStream . write ( 'Invalid REPL keyword\n' ) ;
418
- skipCatchall = true ;
417
+ finish ( null ) ;
418
+ return ;
419
419
}
420
420
}
421
421
422
- if ( ! skipCatchall && ( cmd || ( ! cmd && self . bufferedCommand ) ) ) {
422
+ if ( cmd || self . bufferedCommand ) {
423
423
var evalCmd = self . bufferedCommand + cmd ;
424
424
if ( / ^ \s * \{ / . test ( evalCmd ) && / \} \s * $ / . test ( evalCmd ) ) {
425
425
// It's confusing for `{ a : 1 }` to be interpreted as a block
@@ -1002,7 +1002,7 @@ REPLServer.prototype.memory = function memory(cmd) {
1002
1002
// self.lines.level.length === 0
1003
1003
// TODO? keep a log of level so that any syntax breaking lines can
1004
1004
// be cleared on .break and in the case of a syntax error?
1005
- // TODO? if a log was kept, then I could clear the bufferedComand and
1005
+ // TODO? if a log was kept, then I could clear the bufferedCommand and
1006
1006
// eval these lines and throw the syntax error
1007
1007
} else {
1008
1008
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