Skip to content

Commit

Permalink
add outputFile option
Browse files Browse the repository at this point in the history
closes #44
  • Loading branch information
sindresorhus committed Jan 25, 2015
1 parent 32267c4 commit 1b1f43a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ Name of a [built-in formatter](https://github.com/nzakas/eslint/tree/master/lib/
Some formatters you might find useful: [eslint-json](https://github.com/sindresorhus/eslint-json), [eslint-tap](https://github.com/sindresorhus/eslint-tap).


### outputFile

Type: `boolean`
Default: `false`

Output the report to a file.


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)
10 changes: 9 additions & 1 deletion tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function calculateExitCode(results) {
module.exports = function (grunt) {
grunt.registerMultiTask('eslint', 'Validate files with ESLint', function () {
var opts = this.options({
outputFile: false,
format: 'stylish'
});

Expand All @@ -40,7 +41,14 @@ module.exports = function (grunt) {
return;
}

console.log(formatter(results));
var output = formatter(results);

if (opts.outputFile) {
grunt.file.write(opts.outputFile, output);
} else {
console.log(output);
}

return calculateExitCode(results) === 0;
});
};

0 comments on commit 1b1f43a

Please sign in to comment.