tasks/ftp_push.js
function pushDirectories(directories, callback) {
    var index = 0;

    /**
    * Recursive helper used as callback for server.raw(mkd)
    * @param {error} err - Error message if something went wrong
    */
    var processDir = function processDir (err) {
      // Fail if any error other then 550 is present, 550 is Directory Already Exists
      // these directories must exist to continue
      if (err) {
        if (err.code !== 550) { grunt.fail.warn(err); }
      } else {
        grunt.log.ok(messages.directoryCreated(directories[index]));
      }

      ++index;
      // If there is more directories to process then keep going
      if (index < directories.length) {
        server.raw('mkd', directories[index], processDir);
      } else {
        callback();
      }
    };

    // Start processing dirs or end if none are present
    if (index < directories.length) {
      server.raw('mkd', directories[index], processDir);
    } else {
      callback();
    }
  }
function pushDirectories(directories, callback) {
    var index = 0;

    /**
    * Recursive helper used as callback for server.raw(mkd)
    * @param {error} err - Error message if something went wrong
    */
    var processDir = function processDir (err) {
      // Fail if any error other then 550 is present, 550 is Directory Already Exists
      // these directories must exist to continue
      if (err) {
        if (err.code !== 550) { grunt.fail.warn(err); }
      } else {
        grunt.log.ok(messages.directoryCreated(directories[index]));
      }

      ++index;
      // If there is more directories to process then keep going
      if (index < directories.length) {
        server.raw('mkd', directories[index], processDir);
      } else {
        callback();
      }
    };

    // Start processing dirs or end if none are present
    if (index < directories.length) {
      server.raw('mkd', directories[index], processDir);
    } else {
      callback();
    }
  }
function pushDirectories ( directories , callback ) { var index = 0 ; /**
    * Recursive helper used as callback for server.raw(mkd)
    * @param {error} err - Error message if something went wrong
    */ var processDir = function processDir ( err ) { // Fail if any error other then 550 is present, 550 is Directory Already Exists // these directories must exist to continue if ( err ) { if ( err . code !== 550 ) { grunt . fail . warn ( err ) ; } } else { grunt . log . ok ( messages . directoryCreated ( directories [ index ] ) ) ; } ++ index ; // If there is more directories to process then keep going if ( index < directories . length ) { server . raw ( 'mkd' , directories [ index ] , processDir ) ; } else { callback ( ) ; } } ; // Start processing dirs or end if none are present if ( index < directories . length ) { server . raw ( 'mkd' , directories [ index ] , processDir ) ; } else { callback ( ) ; } }
Helper function that uses a recursive style for creating directories until none remain
@param {array} directories - Array of directory paths that will be necessary to upload files
@param {function} callback - function to trigger when all directories have been created
Helper function that uses a recursive style for creating directories until none remain