0

I am currently running a set of tasks inside a for loop in grunt. Ex: data.accounts.forEach(function(payload){ grunt.task.run('exec:task1:'+payload.account+':'+payload.password); grunt.task.run('exec:task2:'+payload.account+':'+payload.password+':'+payload.first_name); });

Currently the way this is working is if any one of these exec fails then the whole batch fails. I was wondering if there was a way to continue on through the loop even if one of these failed. Like some sort of try/catch.

After thinking about my question for a minute this may be a grunt-exec issue. here is my code for my exec:

      exec: {
        task1: {
          cmd: function(account, password){
            return 'node node_module ' + account + ' ' + password
          }
      },
         task2: {
          cmd: function(account, password, first_name){
            return 'node node_module ' + account + ' ' + password + ' ' + first_name
    }
  }

1 Answers1

0

The answer to this lies in the grunt-exec

      exec: {
    task1: {
      cmd: function(account, password){
        return 'node node_module ' + account + ' ' + password
      },
      exitCodes: [0,1]
      },
    task2: {
      cmd: function(account, password, first_name){
        return 'node node_module ' + account + ' ' + password + ' ' + first_name
      },
      exitCodes: [0,1]
}