@@ -22,10 +22,10 @@ loggingSettings = {
2222var fs = require ( "fs" ) ,
2323 babelParser = require ( "babylon" ) ,
2424 traverse = require ( "babel-traverse" ) ,
25+ split = require ( 'split' ) ,
2526 logger = require ( './helpers/logger' ) ( loggingSettings ) ,
2627 path = require ( "path" ) ,
2728 es5_visitors = require ( "./visitors/es5-visitors" ) ,
28- lazy = require ( "lazy" ) ,
2929 eol = require ( 'os' ) . EOL ,
3030
3131 BUILD_TOOLS_DIR = `${ __dirname } /../` ,
@@ -99,17 +99,20 @@ readLinesFromFile(inputFilesPath, inputFiles, tsHelpersFilePath)
9999*/
100100function readLinesFromFile ( filePath , outArr , resolveParameter ) {
101101 return new Promise ( function ( resolve , reject ) {
102- new lazy ( fs . createReadStream ( filePath ) )
103- . lines
104- . forEach ( function ( line ) {
102+ fs . createReadStream ( filePath )
103+ . pipe ( split ( ) )
104+ . on ( 'data' , function ( line ) {
105+ // skip empty lines
106+ if ( / \S / . test ( line ) ) {
105107 outArr . push ( line . toString ( ) . trim ( ) ) ;
106- } ) . on ( 'pipe' , function ( err ) {
107- if ( err ) {
108- return reject ( err ) ;
109- }
110-
111- return resolve ( resolveParameter )
112- } ) ;
108+ }
109+ } )
110+ . on ( 'error' , function ( err ) {
111+ return reject ( err ) ;
112+ } )
113+ . on ( 'close' , function ( e ) {
114+ return resolve ( resolveParameter )
115+ } ) ;
113116 } ) ;
114117}
115118
@@ -144,19 +147,21 @@ function getFileAst(tsHelpersFilePath) {
144147*/
145148function readInterfaceNames ( data , err ) {
146149 return new Promise ( function ( resolve , reject ) {
147- new lazy ( fs . createReadStream ( interfacesNamesFilePath ) )
148- . lines
149- . forEach ( function ( line ) {
150- interfaceNames . push ( line . toString ( ) ) ;
151- } ) . on ( 'pipe' , function ( err ) {
152- if ( err ) {
153- return reject ( false ) ;
154- }
155-
156- inputDir = path . normalize ( inputDir ) ;
157-
158- return resolve ( inputDir ) ;
159- } ) ;
150+ fs . createReadStream ( interfacesNamesFilePath )
151+ . pipe ( split ( ) )
152+ . on ( 'data' , function ( line ) {
153+ // skip empty lines
154+ if ( / \S / . test ( line ) ) {
155+ interfaceNames . push ( line . toString ( ) . trim ( ) ) ;
156+ }
157+ } )
158+ . on ( 'error' , function ( e ) {
159+ return reject ( false ) ;
160+ } )
161+ . on ( 'close' , function ( e ) {
162+ inputDir = path . normalize ( inputDir ) ;
163+ return resolve ( inputDir ) ;
164+ } ) ;
160165 } )
161166}
162167
0 commit comments