@@ -242,7 +242,7 @@ function REPLServer(prompt,
242242 var err , result , retry = false , input = code , wrappedErr ;
243243 // first, create the Script object to check the syntax
244244
245- if ( code === '\n' || code === '\r\n' )
245+ if ( code === '\n' )
246246 return cb ( null ) ;
247247
248248 while ( true ) {
@@ -251,7 +251,7 @@ function REPLServer(prompt,
251251 ( self . replMode === exports . REPL_MODE_STRICT || retry ) ) {
252252 // "void 0" keeps the repl from returning "use strict" as the
253253 // result value for let/const statements.
254- code = `'use strict'; void 0;\r\ n${ code } ` ;
254+ code = `'use strict'; void 0;\n${ code } ` ;
255255 }
256256 var script = vm . createScript ( code , {
257257 filename : file ,
@@ -265,7 +265,7 @@ function REPLServer(prompt,
265265 if ( self . wrappedCmd ) {
266266 self . wrappedCmd = false ;
267267 // unwrap and try again
268- code = `${ input . substring ( 1 , input . length - 2 ) } \r\ n` ;
268+ code = `${ input . substring ( 1 , input . length - 2 ) } \n` ;
269269 wrappedErr = e ;
270270 } else {
271271 retry = true ;
@@ -367,7 +367,7 @@ function REPLServer(prompt,
367367 e . stack = e . stack . replace ( / ( \s + a t \s + r e p l : ) ( \d + ) / ,
368368 ( _ , pre , line ) => pre + ( line - 1 ) ) ;
369369 }
370- top . outputStream . write ( ( e . stack || e ) + '\r\ n' ) ;
370+ top . outputStream . write ( ( e . stack || e ) + '\n' ) ;
371371 top . lineParser . reset ( ) ;
372372 top . bufferedCommand = '' ;
373373 top . lines . level = [ ] ;
@@ -453,7 +453,7 @@ function REPLServer(prompt,
453453 sawSIGINT = false ;
454454 return ;
455455 }
456- self . output . write ( '(To exit, press ^C again or type .exit)\r\ n' ) ;
456+ self . output . write ( '(To exit, press ^C again or type .exit)\n' ) ;
457457 sawSIGINT = true ;
458458 } else {
459459 sawSIGINT = false ;
@@ -470,7 +470,7 @@ function REPLServer(prompt,
470470 sawSIGINT = false ;
471471
472472 if ( self . editorMode ) {
473- self . bufferedCommand += cmd + '\r\ n' ;
473+ self . bufferedCommand += cmd + '\n' ;
474474 return ;
475475 }
476476
@@ -490,7 +490,7 @@ function REPLServer(prompt,
490490 if ( self . parseREPLKeyword ( keyword , rest ) === true ) {
491491 return ;
492492 } else if ( ! self . bufferedCommand ) {
493- self . outputStream . write ( 'Invalid REPL keyword\r\ n' ) ;
493+ self . outputStream . write ( 'Invalid REPL keyword\n' ) ;
494494 finish ( null ) ;
495495 return ;
496496 }
@@ -509,8 +509,8 @@ function REPLServer(prompt,
509509 self . wrappedCmd = false ;
510510 if ( e && ! self . bufferedCommand && cmd . trim ( ) . startsWith ( 'npm ' ) ) {
511511 self . outputStream . write ( 'npm should be run outside of the ' +
512- 'node repl, in your normal shell.\r\ n' +
513- '(Press Control-D to exit.)\r\ n' ) ;
512+ 'node repl, in your normal shell.\n' +
513+ '(Press Control-D to exit.)\n' ) ;
514514 self . lineParser . reset ( ) ;
515515 self . bufferedCommand = '' ;
516516 self . displayPrompt ( ) ;
@@ -525,7 +525,7 @@ function REPLServer(prompt,
525525 // {
526526 // ... x: 1
527527 // ... }
528- self . bufferedCommand += cmd + '\r\ n' ;
528+ self . bufferedCommand += cmd + '\n' ;
529529 self . displayPrompt ( ) ;
530530 return ;
531531 } else {
@@ -548,7 +548,7 @@ function REPLServer(prompt,
548548 if ( ! self . underscoreAssigned ) {
549549 self . last = ret ;
550550 }
551- self . outputStream . write ( self . writer ( ret ) + '\r\ n' ) ;
551+ self . outputStream . write ( self . writer ( ret ) + '\n' ) ;
552552 }
553553
554554 // Display prompt again
@@ -578,10 +578,10 @@ function REPLServer(prompt,
578578
579579 self . on ( 'SIGCONT' , function ( ) {
580580 if ( self . editorMode ) {
581- self . outputStream . write ( `${ self . _initialPrompt } .editor\r\ n` ) ;
581+ self . outputStream . write ( `${ self . _initialPrompt } .editor\n` ) ;
582582 self . outputStream . write (
583- '// Entering editor mode (^D to finish, ^C to cancel)\r\ n' ) ;
584- self . outputStream . write ( `${ self . bufferedCommand } \r\ n` ) ;
583+ '// Entering editor mode (^D to finish, ^C to cancel)\n' ) ;
584+ self . outputStream . write ( `${ self . bufferedCommand } \n` ) ;
585585 self . prompt ( true ) ;
586586 } else {
587587 self . displayPrompt ( true ) ;
@@ -713,7 +713,7 @@ REPLServer.prototype.createContext = function() {
713713 this . last = value ;
714714 if ( ! this . underscoreAssigned ) {
715715 this . underscoreAssigned = true ;
716- this . outputStream . write ( 'Expression assignment to _ now disabled.\r\ n' ) ;
716+ this . outputStream . write ( 'Expression assignment to _ now disabled.\n' ) ;
717717 }
718718 }
719719 } ) ;
@@ -762,7 +762,7 @@ function ArrayStream() {
762762 this . run = function ( data ) {
763763 var self = this ;
764764 data . forEach ( function ( line ) {
765- self . emit ( 'data' , line + '\r\ n' ) ;
765+ self . emit ( 'data' , line + '\n' ) ;
766766 } ) ;
767767 } ;
768768}
@@ -1232,7 +1232,7 @@ function defineDefaultCommands(repl) {
12321232 this . lineParser . reset ( ) ;
12331233 this . bufferedCommand = '' ;
12341234 if ( ! this . useGlobal ) {
1235- this . outputStream . write ( 'Clearing context...\r\ n' ) ;
1235+ this . outputStream . write ( 'Clearing context...\n' ) ;
12361236 this . resetContext ( ) ;
12371237 }
12381238 this . displayPrompt ( ) ;
@@ -1252,7 +1252,7 @@ function defineDefaultCommands(repl) {
12521252 var self = this ;
12531253 Object . keys ( this . commands ) . sort ( ) . forEach ( function ( name ) {
12541254 var cmd = self . commands [ name ] ;
1255- self . outputStream . write ( name + '\t' + ( cmd . help || '' ) + '\r\ n' ) ;
1255+ self . outputStream . write ( name + '\t' + ( cmd . help || '' ) + '\n' ) ;
12561256 } ) ;
12571257 this . displayPrompt ( ) ;
12581258 }
@@ -1262,10 +1262,10 @@ function defineDefaultCommands(repl) {
12621262 help : 'Save all evaluated commands in this REPL session to a file' ,
12631263 action : function ( file ) {
12641264 try {
1265- fs . writeFileSync ( file , this . lines . join ( '\r\ n' ) + '\r \n' ) ;
1266- this . outputStream . write ( 'Session saved to:' + file + '\r\ n' ) ;
1265+ fs . writeFileSync ( file , this . lines . join ( '\n' ) + '\n' ) ;
1266+ this . outputStream . write ( 'Session saved to:' + file + '\n' ) ;
12671267 } catch ( e ) {
1268- this . outputStream . write ( 'Failed to save:' + file + '\r\ n' ) ;
1268+ this . outputStream . write ( 'Failed to save:' + file + '\n' ) ;
12691269 }
12701270 this . displayPrompt ( ) ;
12711271 }
@@ -1279,21 +1279,19 @@ function defineDefaultCommands(repl) {
12791279 if ( stats && stats . isFile ( ) ) {
12801280 var self = this ;
12811281 var data = fs . readFileSync ( file , 'utf8' ) ;
1282- // \r\n, \n, or \r followed by something other than \n
1283- const lineEnding = / \r ? \n | \r (? ! \n ) / ;
1284- var lines = data . split ( lineEnding ) ;
1282+ var lines = data . split ( '\n' ) ;
12851283 this . displayPrompt ( ) ;
12861284 lines . forEach ( function ( line ) {
12871285 if ( line ) {
1288- self . write ( line + '\r\ n' ) ;
1286+ self . write ( line + '\n' ) ;
12891287 }
12901288 } ) ;
12911289 } else {
12921290 this . outputStream . write ( 'Failed to load:' + file +
1293- ' is not a valid file\r\ n' ) ;
1291+ ' is not a valid file\n' ) ;
12941292 }
12951293 } catch ( e ) {
1296- this . outputStream . write ( 'Failed to load:' + file + '\r\ n' ) ;
1294+ this . outputStream . write ( 'Failed to load:' + file + '\n' ) ;
12971295 }
12981296 this . displayPrompt ( ) ;
12991297 }
@@ -1306,7 +1304,7 @@ function defineDefaultCommands(repl) {
13061304 this . editorMode = true ;
13071305 REPLServer . super_ . prototype . setPrompt . call ( this , '' ) ;
13081306 this . outputStream . write (
1309- '// Entering editor mode (^D to finish, ^C to cancel)\r\ n' ) ;
1307+ '// Entering editor mode (^D to finish, ^C to cancel)\n' ) ;
13101308 }
13111309 } ) ;
13121310}
0 commit comments