lib/utils.js
function iterateRecurse (dir, options, cb) {
  try {
    var files = fs.readdirSync(dir)
    files.forEach(function (file, index) {
      var parsedPath = path.parse(file)
      var name = parsedPath.name
      var ext = parsedPath.ext
      var srcpath = path.join(dir, file)

      if (options.skip_ && name.charAt(0) === '_') {
        logger.debug('Skipping file/folder: ' + srcpath)
      } else {
        if (fs.lstatSync(srcpath).isDirectory()) {
          if (options.dirs) {
            cb(srcpath, name)
          }

          // Do recursive search when needed
          if (options.recursive) {
            iterateRecurse(srcpath, options, cb)
          }
        } else {
          for (var i = 0; i < options.ext.length; i++) {
            if (ext === options.ext[i]) {
              cb(srcpath, name, ext)
            }
          }
        }
      }
    })
  } catch (e) {
    logger.debug('Error iterating files: ' + e)
  }
}
function iterateRecurse (dir, options, cb) {
  try {
    var files = fs.readdirSync(dir)
    files.forEach(function (file, index) {
      var parsedPath = path.parse(file)
      var name = parsedPath.name
      var ext = parsedPath.ext
      var srcpath = path.join(dir, file)

      if (options.skip_ && name.charAt(0) === '_') {
        logger.debug('Skipping file/folder: ' + srcpath)
      } else {
        if (fs.lstatSync(srcpath).isDirectory()) {
          if (options.dirs) {
            cb(srcpath, name)
          }

          // Do recursive search when needed
          if (options.recursive) {
            iterateRecurse(srcpath, options, cb)
          }
        } else {
          for (var i = 0; i < options.ext.length; i++) {
            if (ext === options.ext[i]) {
              cb(srcpath, name, ext)
            }
          }
        }
      }
    })
  } catch (e) {
    logger.debug('Error iterating files: ' + e)
  }
}
function iterateRecurse ( dir , options , cb ) { try { var files = fs . readdirSync ( dir ) files . forEach ( function ( file , index ) { var parsedPath = path . parse ( file ) var name = parsedPath . name var ext = parsedPath . ext var srcpath = path . join ( dir , file ) if ( options . skip_ && name . charAt ( 0 ) === '_' ) { logger . debug ( 'Skipping file/folder: ' + srcpath ) } else { if ( fs . lstatSync ( srcpath ) . isDirectory ( ) ) { if ( options . dirs ) { cb ( srcpath , name ) } // Do recursive search when needed if ( options . recursive ) { iterateRecurse ( srcpath , options , cb ) } } else { for ( var i = 0 ; i < options . ext . length ; i ++ ) { if ( ext === options . ext [ i ] ) { cb ( srcpath , name , ext ) } } } } } ) } catch ( e ) { logger . debug ( 'Error iterating files: ' + e ) } }
Private recursive method for doing the above
Private recursive method for doing the above