Skip to content

Commit

Permalink
make relative reporterOutput paths optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sjhewitt committed Jul 30, 2015
1 parent edf46ca commit 506dc54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion tasks/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ module.exports = function(grunt) {
// Merge task-specific and/or target-specific options with these defaults.
var options = this.options({
force: false,
reporter: null
reporter: null,
reporterOutputRelative: true
});

// Report JSHint errors but dont fail the task
Expand Down
14 changes: 9 additions & 5 deletions tasks/lib/jshint.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,17 @@ exports.init = function(grunt) {
var reporterOutputDir;
// Get reporter output directory for relative paths in reporters
if (options.hasOwnProperty('reporterOutput')) {
reporterOutputDir = path.dirname(options.reporterOutput);
if(options.reporterOutputRelative) {
reporterOutputDir = path.dirname(options.reporterOutput);
}
delete options.reporterOutput;
}

// Select a reporter to use
var reporter = exports.selectReporter(options);

// Remove bad options that may have came in from the cli
['reporter', 'jslint-reporter', 'checkstyle-reporter', 'show-non-errors'].forEach(function(opt) {
['reporter', 'reporterOutputRelative', 'jslint-reporter', 'checkstyle-reporter', 'show-non-errors'].forEach(function(opt) {
if (options.hasOwnProperty(opt)) {
delete options[opt];
}
Expand Down Expand Up @@ -194,9 +196,11 @@ exports.init = function(grunt) {
var allData = [];
cliOptions.args = files;
cliOptions.reporter = function(results, data) {
results.forEach(function(datum) {
datum.file = reporterOutputDir ? path.relative(reporterOutputDir, datum.file) : datum.file;
});
if(reporterOutputDir) {
results.forEach(function(datum) {
datum.file = path.relative(reporterOutputDir, datum.file);
});
}
reporter(results, data, options);
allResults = allResults.concat(results);
allData = allData.concat(data);
Expand Down

0 comments on commit 506dc54

Please sign in to comment.