简体   繁体   中英

Is it possible to have more than one reporter & reporterOutput in jshint?

In my options, I have a reporter and reporterOutput defined on my grunt task for jshint. But I'd like to write out two files from the same data. Is it possible with jshint using the options or do I just need to define 2 grunt tasks that will do the same thing but output different formats of the same results?

I also want to do the same thing with jscs output.

In your custom reporter, in order to create the output file you just return the following code:

process.stdout.write(reportHtmlJS);

Let's imagine reporterHTMLJS is your custom HTML output. What you can do before that is just use that HTML and create a second file, before the JSHint or JSCS module creates it. Something similar to that:

fs = require('fs');
fs.writeFile("./jshint/secondJSHintReport.html", reportHtmlJS, function (err) {
    if (err) {
        console.log(err);
    }
});

You can also use some Grunt module, like grunt-contrib-copy and grunt-contrib-rename , and create new grunt task that will execute first jshint/jscs and then copy the file and rename it.

grunt.task.run("jshint copy:jshint rename:jshint");
grunt.task.run("jscs copy:jscs rename:jscs");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM