Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use relative paths, print the line source more robustly #9

Merged
merged 1 commit into from

2 participants

@beaugunderson

Couple of improvements, the first being relative paths--this lets you much more easily serve HTML covershot reports from the web, or via a quick python -mSimpleHTTPServer. I develop remotely on a Linode box and thus don't have the coverage report on my local system. I also run covershot on our Jenkins instance and the relative paths are needed for web viewing there as well. It should not affect local filesystem viewing.

The other improvement looks to be a quirk in some versions of jscoverage--my version writes its source output as { "3": { source: "source of the line here" } } whereas it looks like covershot expects it to be in the format { "3": { line: "source of the line here" } }, my change will accept either variant and so does not proscribe a specific version for the end user. (I'm using the one at visionmedia/node-jscoverage, FYI)

This was referenced
@kunklejr kunklejr merged commit 6eaeac6 into kunklejr:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 6 deletions.
  1. +8 −5 lib/format/html/index.js
  2. +1 −1  lib/format/html/src.ejs
View
13 lib/format/html/index.js
@@ -25,10 +25,12 @@ function writeSource(outputDir, data, callback) {
try {
var outFile = path.join(outputDir, 'src', data.filename + '.html');
var template = path.join(__dirname, 'src.ejs');
+ var relativePath = path.relative(path.dirname(outFile), outputDir);
+
+ data.pathToCSS = path.join(relativePath, 'css');
+ data.pathToScripts = path.join(relativePath, 'scripts');
+ data.pathToRoot = relativePath;
- data.pathToCSS = path.resolve(path.join(outputDir, 'css'));
- data.pathToScripts = path.resolve(path.join(outputDir, 'scripts'));
- data.pathToRoot = path.resolve(outputDir);
data.green = getColoredLines(data, function (c) {return c >= 1; });
data.red = getColoredLines(data, function (c) {return c === 0; });
data.generated = new Date().toString();
@@ -92,7 +94,8 @@ function copyResources(outputDir) {
}
exports.report = function (coverageMap, outputDir, callback) {
- var outputDir = outputDir || 'covershot';
+ outputDir = outputDir || 'covershot';
+
coverageMap.generated = new Date().toString();
coverageMap.files = sortFiles(coverageMap.files);
@@ -160,4 +163,4 @@ function renderPieChart(percent) {
}
html += '</svg>';
return html;
-}
+}
View
2  lib/format/html/src.ejs
@@ -56,7 +56,7 @@
<section id="bod">
<section id="mainContent">
<script type="syntaxhighlighter" class="brush: js; class-name: 'rounded'"><![CDATA[<% for (var i in source) { %>
-<%- source[i].line %><% } %> ]]></script>
+<%- (source[i].line || source[i].source) %><% } %> ]]></script>
</section>
</section>
</div>
Something went wrong with that request. Please try again.