tasks/sftp-deploy.js
function dirParseSync(startDir, result) {
    var files;
    var i;
    var tmpPath;
    var currFile;

    // initialize the `result` object if it is the first iteration
    if (result === undefined) {
      result = {};
      result[localSep] = [];
    }

    // check if `startDir` is a valid location
    if (!fs.existsSync(startDir)) {
      grunt.warn(startDir + ' is not an existing location');
    }

    // iterate throught the contents of the `startDir` location of the current iteration
    files = fs.readdirSync(startDir);
    for (i = 0; i < files.length; i++) {
      currFile = startDir + localSep + files[i];
      if (!file.isMatch({matchBase: true}, exclusions, currFile)) {
        if (file.isDir(currFile)) {
          tmpPath = path.relative(localRoot, startDir + localSep + files[i]);
          if (!_.has(result, tmpPath)) {
            result[tmpPath] = [];
          }
          dirParseSync(currFile, result);
        } else {
          tmpPath = path.relative(localRoot, startDir);
          if (!tmpPath.length) {
            tmpPath = localSep;
          }
          result[tmpPath].push(files[i]);
        }
      }
    }

    return result;
  }
function dirParseSync(startDir, result) {
    var files;
    var i;
    var tmpPath;
    var currFile;

    // initialize the `result` object if it is the first iteration
    if (result === undefined) {
      result = {};
      result[localSep] = [];
    }

    // check if `startDir` is a valid location
    if (!fs.existsSync(startDir)) {
      grunt.warn(startDir + ' is not an existing location');
    }

    // iterate throught the contents of the `startDir` location of the current iteration
    files = fs.readdirSync(startDir);
    for (i = 0; i < files.length; i++) {
      currFile = startDir + localSep + files[i];
      if (!file.isMatch({matchBase: true}, exclusions, currFile)) {
        if (file.isDir(currFile)) {
          tmpPath = path.relative(localRoot, startDir + localSep + files[i]);
          if (!_.has(result, tmpPath)) {
            result[tmpPath] = [];
          }
          dirParseSync(currFile, result);
        } else {
          tmpPath = path.relative(localRoot, startDir);
          if (!tmpPath.length) {
            tmpPath = localSep;
          }
          result[tmpPath].push(files[i]);
        }
      }
    }

    return result;
  }
function dirParseSync ( startDir , result ) { var files ; var i ; var tmpPath ; var currFile ; // initialize the `result` object if it is the first iteration if ( result === undefined ) { result = { } ; result [ localSep ] = [ ] ; } // check if `startDir` is a valid location if ( ! fs . existsSync ( startDir ) ) { grunt . warn ( startDir + ' is not an existing location' ) ; } // iterate throught the contents of the `startDir` location of the current iteration files = fs . readdirSync ( startDir ) ; for ( i = 0 ; i < files . length ; i ++ ) { currFile = startDir + localSep + files [ i ] ; if ( ! file . isMatch ( { matchBase : true } , exclusions , currFile ) ) { if ( file . isDir ( currFile ) ) { tmpPath = path . relative ( localRoot , startDir + localSep + files [ i ] ) ; if ( ! _ . has ( result , tmpPath ) ) { result [ tmpPath ] = [ ] ; } dirParseSync ( currFile , result ) ; } else { tmpPath = path . relative ( localRoot , startDir ) ; if ( ! tmpPath . length ) { tmpPath = localSep ; } result [ tmpPath ] . push ( files [ i ] ) ; } } } return result ; }
A method for parsing the source location and storing the information into a suitably formated object
A method for parsing the source location and storing the information into a suitably formated object