Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run all targets before failing #168

Open
dharkness opened this issue May 27, 2014 · 2 comments
Open

Run all targets before failing #168

dharkness opened this issue May 27, 2014 · 2 comments

Comments

@dharkness
Copy link

Our project have four targets for JSHint as some require different .jshintrc options. When you don't specify a target, all are executed which is perfect. However, the other targets are skipped as soon as one reports errors. Using --force or the force option runs all the targets, but then the task itself passes.

I would like all targets to be processed and have the task pass only if each target passed. My current workaround is very cumbersome and repeats information:

grunt.registerTask("lint", "Check coding standards", function(target) {
    if (target) {
        grunt.task.run("jshint:" + target);
    }
    else {
        var done = this.async(),
            targets = { gruntfile: 0, src: 0, lib: 0, test: 0 };
        grunt.util.async.forEachSeries(Object.keys(targets), function(target, next) {
            grunt.util.spawn({
                grunt: true,
                args: [ "jshint:" + target ],
                opts: { stdio: "inherit" }
            }, function(error, result, code) {
                targets[target] = code;
                next();
            });
        }, function() {
            Object.keys(targets).forEach(function(target) {
                var code = targets[target];
                code && grunt.fail.fatal(target + " lint failed.", code);
            });
            done();
        });
    }
});

Is there an easier way that I'm missing? If not, could we extend the force option to add a value that would continue the task and fail at the end if any target had errors? Ideally, omitting force entirely would work like this, but others may be depending on this fail-fast behavior.

@jordanst3wart
Copy link

I don't think jshint should fail and stop the grunt build at all.

@atdiff
Copy link

atdiff commented May 11, 2016

@dharkness were you able to figure out another way to handle this? I'd like to do the same process - execute all tasks before failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants