11const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
23
34const args = process . argv . slice ( 2 ) ;
45const dir = args [ 0 ] ;
@@ -222,21 +223,20 @@ var SourceFileOperations = [
222223] ;
223224
224225var paths = listFiles ( dir ) ;
225- paths . forEach ( function ( path ) {
226- var filename = path . split ( '\\' ) . pop ( ) . split ( '/' ) . pop ( ) ;
226+ paths . forEach ( function ( dirEntry ) {
227+ var filename = dirEntry . split ( '\\' ) . pop ( ) . split ( '/' ) . pop ( ) ;
227228
228229 // Check whether the file is a source file or a config file
229230 // then execute function accordingly
230231 var sourcePattern = / .+ \. h | .+ \. c c | .+ \. c p p / ;
231232 if ( sourcePattern . test ( filename ) ) {
232- convertFile ( path , SourceFileOperations ) ;
233+ convertFile ( dirEntry , SourceFileOperations ) ;
233234 } else if ( ConfigFileOperations [ filename ] != null ) {
234- convertFile ( path , ConfigFileOperations [ filename ] ) ;
235+ convertFile ( dirEntry , ConfigFileOperations [ filename ] ) ;
235236 }
236237} ) ;
237238
238239function listFiles ( dir , filelist ) {
239- var path = path || require ( 'path' ) ;
240240 files = fs . readdirSync ( dir ) ;
241241 filelist = filelist || [ ] ;
242242 files . forEach ( function ( file ) {
@@ -257,13 +257,13 @@ function convert(content, operations) {
257257 return content ;
258258}
259259
260- function convertFile ( path , operations ) {
261- fs . readFile ( path , "utf-8" , function ( err , file ) {
260+ function convertFile ( fileName , operations ) {
261+ fs . readFile ( fileName , "utf-8" , function ( err , file ) {
262262 if ( err ) throw err ;
263263
264264 file = convert ( file , operations ) ;
265265
266- fs . writeFile ( path , file , function ( err ) {
266+ fs . writeFile ( fileName , file , function ( err ) {
267267 if ( err ) throw err ;
268268 } ) ;
269269 } ) ;
0 commit comments