source/defaultWorkflow/defaultWorkflow.js
function defaultWorkflow(opts) {
  var tasks;
  var paths;
  var runnableTasks;
  var runnablePaths;

  return execP('git status')
    .then(function() {
      return getUnchanged(opts.globs);
    })
    .spread(function(a, b) {
      tasks = a;
      paths = b;
      console.log(
        'Executing: ' + '`git stash && git add . && git stash`.\n'.italic
      );
      return gitCmds.safeStashAll();
    })
    .then(function() {
      console.log(
        'Repo reverted to clean state. Looking at previous screenshots...\n'
      );
      console.log(
        'If anything goes wrong'.bold + ', simply run ' +
        '`git stash pop && git reset HEAD . && git stash pop --index` '.italic +
        'to restore your changes.'
      );
      // TODO: not good enough. Warn earlier about no task. Before stash
      var res = filterRunnables(tasks, paths, opts.taskName);
      runnableTasks = res[0];
      runnablePaths = res[1];

      return runTasks(writeScreenshots, opts, runnableTasks, runnablePaths);
    })
    .catch(function(e) {
      if (e.name === 'OperationalError' &&
          e.message.indexOf('Not a git repository') > -1) {
        return Promise.reject(new Error(notGitMsg));
      }

      return gitCmds
        .safeUnstashAll()
        .then(function() {
          return Promise.reject(e);
        });
    })
    .then(function() {
      console.log(
        'Executing: ' +
        '`git stash pop && git reset HEAD . && git stash pop --index`.\n'.italic
      );
      return gitCmds.safeUnstashAll();
    })
    .then(function() {
      console.log(
        'Repo back to modified state. Getting new screenshots and comparing ' +
        'them with previously recorded ones...\n'
      );
      return runTasks(compareScreenshots, opts, runnableTasks, runnablePaths);
    })
    .then(function() {
      return Promise.map(paths, function(dir, i) {
        return Promise.map(tasks[i], function(task) {
          var p = path.join(
            dir,
            consts.HUXLEY_FOLDER_NAME,
            task.name + consts.TASK_FOLDER_SUFFIX
          );
          return removeDirIfOk(p);
        });
      });
    });
}
function defaultWorkflow(opts) {
  var tasks;
  var paths;
  var runnableTasks;
  var runnablePaths;

  return execP('git status')
    .then(function() {
      return getUnchanged(opts.globs);
    })
    .spread(function(a, b) {
      tasks = a;
      paths = b;
      console.log(
        'Executing: ' + '`git stash && git add . && git stash`.\n'.italic
      );
      return gitCmds.safeStashAll();
    })
    .then(function() {
      console.log(
        'Repo reverted to clean state. Looking at previous screenshots...\n'
      );
      console.log(
        'If anything goes wrong'.bold + ', simply run ' +
        '`git stash pop && git reset HEAD . && git stash pop --index` '.italic +
        'to restore your changes.'
      );
      // TODO: not good enough. Warn earlier about no task. Before stash
      var res = filterRunnables(tasks, paths, opts.taskName);
      runnableTasks = res[0];
      runnablePaths = res[1];

      return runTasks(writeScreenshots, opts, runnableTasks, runnablePaths);
    })
    .catch(function(e) {
      if (e.name === 'OperationalError' &&
          e.message.indexOf('Not a git repository') > -1) {
        return Promise.reject(new Error(notGitMsg));
      }

      return gitCmds
        .safeUnstashAll()
        .then(function() {
          return Promise.reject(e);
        });
    })
    .then(function() {
      console.log(
        'Executing: ' +
        '`git stash pop && git reset HEAD . && git stash pop --index`.\n'.italic
      );
      return gitCmds.safeUnstashAll();
    })
    .then(function() {
      console.log(
        'Repo back to modified state. Getting new screenshots and comparing ' +
        'them with previously recorded ones...\n'
      );
      return runTasks(compareScreenshots, opts, runnableTasks, runnablePaths);
    })
    .then(function() {
      return Promise.map(paths, function(dir, i) {
        return Promise.map(tasks[i], function(task) {
          var p = path.join(
            dir,
            consts.HUXLEY_FOLDER_NAME,
            task.name + consts.TASK_FOLDER_SUFFIX
          );
          return removeDirIfOk(p);
        });
      });
    });
}
function defaultWorkflow ( opts ) { var tasks ; var paths ; var runnableTasks ; var runnablePaths ; return execP ( 'git status' ) . then ( function ( ) { return getUnchanged ( opts . globs ) ; } ) . spread ( function ( a , b ) { tasks = a ; paths = b ; console . log ( 'Executing: ' + '`git stash && git add . && git stash`.\n' . italic ) ; return gitCmds . safeStashAll ( ) ; } ) . then ( function ( ) { console . log ( 'Repo reverted to clean state. Looking at previous screenshots...\n' ) ; console . log ( 'If anything goes wrong' . bold + ', simply run ' + '`git stash pop && git reset HEAD . && git stash pop --index` ' . italic + 'to restore your changes.' ) ; // TODO: not good enough. Warn earlier about no task. Before stash var res = filterRunnables ( tasks , paths , opts . taskName ) ; runnableTasks = res [ 0 ] ; runnablePaths = res [ 1 ] ; return runTasks ( writeScreenshots , opts , runnableTasks , runnablePaths ) ; } ) . catch ( function ( e ) { if ( e . name === 'OperationalError' && e . message . indexOf ( 'Not a git repository' ) > - 1 ) { return Promise . reject ( new Error ( notGitMsg ) ) ; } return gitCmds . safeUnstashAll ( ) . then ( function ( ) { return Promise . reject ( e ) ; } ) ; } ) . then ( function ( ) { console . log ( 'Executing: ' + '`git stash pop && git reset HEAD . && git stash pop --index`.\n' . italic ) ; return gitCmds . safeUnstashAll ( ) ; } ) . then ( function ( ) { console . log ( 'Repo back to modified state. Getting new screenshots and comparing ' + 'them with previously recorded ones...\n' ) ; return runTasks ( compareScreenshots , opts , runnableTasks , runnablePaths ) ; } ) . then ( function ( ) { return Promise . map ( paths , function ( dir , i ) { return Promise . map ( tasks [ i ] , function ( task ) { var p = path . join ( dir , consts . HUXLEY_FOLDER_NAME , task . name + consts . TASK_FOLDER_SUFFIX ) ; return removeDirIfOk ( p ) ; } ) ; } ) ; } ) ; }
will support hg in the future
will support hg in the future