Skip to content

Commit baa5913

Browse files
committed
Merge pull request #214 from qudos-com/master
Make relative reporterOutput paths optional
2 parents cd26571 + efbb6f6 commit baa5913

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

tasks/jshint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module.exports = function(grunt) {
2020
// Merge task-specific and/or target-specific options with these defaults.
2121
var options = this.options({
2222
force: false,
23-
reporter: null
23+
reporter: null,
24+
reporterOutputRelative: true
2425
});
2526

2627
// Report JSHint errors but dont fail the task

tasks/lib/jshint.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,17 @@ exports.init = function(grunt) {
156156
var reporterOutputDir;
157157
// Get reporter output directory for relative paths in reporters
158158
if (options.hasOwnProperty('reporterOutput')) {
159-
reporterOutputDir = path.dirname(options.reporterOutput);
159+
if (options.reporterOutputRelative) {
160+
reporterOutputDir = path.dirname(options.reporterOutput);
161+
}
160162
delete options.reporterOutput;
161163
}
162164

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

166168
// Remove bad options that may have came in from the cli
167-
['reporter', 'jslint-reporter', 'checkstyle-reporter', 'show-non-errors'].forEach(function(opt) {
169+
['reporter', 'reporterOutputRelative', 'jslint-reporter', 'checkstyle-reporter', 'show-non-errors'].forEach(function(opt) {
168170
if (options.hasOwnProperty(opt)) {
169171
delete options[opt];
170172
}
@@ -194,9 +196,11 @@ exports.init = function(grunt) {
194196
var allData = [];
195197
cliOptions.args = files;
196198
cliOptions.reporter = function(results, data) {
197-
results.forEach(function(datum) {
198-
datum.file = reporterOutputDir ? path.relative(reporterOutputDir, datum.file) : datum.file;
199-
});
199+
if (reporterOutputDir) {
200+
results.forEach(function(datum) {
201+
datum.file = path.relative(reporterOutputDir, datum.file);
202+
});
203+
}
200204
reporter(results, data, options);
201205
allResults = allResults.concat(results);
202206
allData = allData.concat(data);

0 commit comments

Comments
 (0)