File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // Context: https://github.com/nodejs/node/issues/45992
4+
5+ require ( '../common' ) ;
6+
7+ const assert = require ( 'assert' ) ;
8+ const fs = require ( 'fs' ) ;
9+ const readline = require ( 'readline' ) ;
10+
11+ const tmpdir = require ( '../common/tmpdir' ) ;
12+
13+ tmpdir . refresh ( ) ;
14+ fs . mkdtempSync ( `${ tmpdir . path } /` ) ;
15+ const path = `${ tmpdir . path } /foo` ;
16+ const writeStream = fs . createWriteStream ( path ) ;
17+
18+ function write ( iteration , callback ) {
19+ for ( ; iteration < 16384 ; iteration += 1 ) {
20+ if ( ! writeStream . write ( 'foo\r\n' ) ) {
21+ writeStream . once ( 'drain' , ( ) => write ( iteration + 1 , callback ) ) ;
22+ return ;
23+ }
24+ }
25+
26+ writeStream . end ( ) ;
27+ callback ( ) ;
28+ }
29+
30+ write ( 0 , ( ) => {
31+ const input = fs . createReadStream ( path ) ;
32+ const rl = readline . createInterface ( { input, crlfDelay : Infinity } ) ;
33+ let carriageReturns = 0 ;
34+
35+ rl . on ( 'line' , ( x ) => {
36+ if ( x . includes ( '\r' ) ) carriageReturns += 1 ;
37+ } ) ;
38+
39+ rl . on ( 'close' , ( ) => {
40+ assert . strictEqual ( carriageReturns , 0 ) ;
41+ } ) ;
42+ } ) ;
You can’t perform that action at this time.
0 commit comments