Skip to content

Commit

Permalink
Merge pull request #214 from qudos-com/master
Browse files Browse the repository at this point in the history
Make relative reporterOutput paths optional
  • Loading branch information
vladikoff committed Jan 23, 2016
2 parents cd26571 + efbb6f6 commit baa5913
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) {

This comment has been minimized.

Copy link
@jsr6720

jsr6720 May 19, 2016

Contributor

is this supposed to be options.reporterOutput? Not sure how Relative is relevant in this context.

At the very least it should check if options.reporterOutput is falsey

See issue #256

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 baa5913

Please sign in to comment.