Skip to content Skip to sidebar Skip to footer

Running Grunt Task Multiple Times Until It Fails

What is the canonical way to run the same grunt task continuously, multiple times until it fails? I'd like to keep the question generic, but here is a specific use case: We have a

Solution 1:

Turns out to be as simple as adding the same task to the array of tasks N times (still not sure if we can somehow avoid specifying the N and run the task indefinitely until it fails) and, since, by default grunt works in the "fail-fast" mode, the whole task would fail on the first fail. In our case:

grunt.registerTask('e2e:local', function () {
    var tasks = ['connect:test'];

    var N = 100;
    for (var i = 0; i < N; i++) {
        tasks.push('protractor:local')
    }

    grunt.task.run(tasks);
});

N here is hardcoded inside the task, but could be passed "from outside" as a grunt option.

Post a Comment for "Running Grunt Task Multiple Times Until It Fails"