Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path.relative call breaks reporter in Windows environment #207

Open
tehtommeh opened this issue Jun 2, 2015 · 0 comments
Open

path.relative call breaks reporter in Windows environment #207

tehtommeh opened this issue Jun 2, 2015 · 0 comments

Comments

@tehtommeh
Copy link

node -v : v0.10.35
grunt version : 0.4.5
grunt-contrib-jshint version : 0.11.2

Running grunt jshint:bamboo using the following GruntFile:

jshint: {
    bamboo: {
        files: {
            src: ['js/*.js']
        },
        options: {
            jshintrc: '.jshintrc',
            reporter: require('jshint-junit-reporter'),
            reporterOutput: 'junit-output.xml'
        }
    }
}

I found that the junit-output.xml file was missing all the <failure> messages. If I removed the reporterOutput, this problem no longer occurred.

I traced the issue back to grunt-contrib-jshint\tasks\lib\jshint.js, lines 197-199:

197       results.forEach(function(datum) { 
198         datum.file = reporterOutputDir ? path.relative(reporterOutputDir, datum.file) : datum.file; 
199       });

When there is no reporterOutputDir (set by reporterOutput), the reporter works as expected. However, when a reporterOutputDir exists, line 198 calls path.relative(reporterOutputDir, datum.file). This creates the path of reporterOutputDir relative to datum.file. However in Windows, this also has the side effect of changing the path to use \ as the delimeter, instead of /.

This may cause potential issues further along, as shown in this example. I believe that the path delimeters should stay consistent after this bit of code executes. I'm not sure what would be the "elegant solution" to this issue would be.

As a side note: Line 198 above does the Boolean check of reporterOutputDir for every single entry in results. This if statement should be moved outside of the foreach loop to save unnecessary re-evalutations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant