Skip to content

Instantly share code, notes, and snippets.

@Ethan-Arrowood
Forked from kohlikohl/script.js
Created December 26, 2018 20:50
Show Gist options
  • Save Ethan-Arrowood/de491e2a6f88ee831963ddf7c75b4076 to your computer and use it in GitHub Desktop.
Save Ethan-Arrowood/de491e2a6f88ee831963ddf7c75b4076 to your computer and use it in GitHub Desktop.
Fix VSTS code coverage reporting by inlining CSS
let fs = require("fs-jetpack"),
path = require("path"),
inline = require("inline-css");
// This inlines the css of the HTML coverage output as VSTS
// strips all external CSS files
const CODE_COVERAGE_DIRECTORY = "./coverage";
const files = fs.find(CODE_COVERAGE_DIRECTORY, { matching: "*.html" });
files.forEach(filePath => {
let options = {
url: "file://" + path.resolve(filePath),
extraCss:
".wrapper {height: initial;} .clearfix { display: inline-block; } table {width: 1px;} .cline-any, .line-count {font-size: 12px;line-height: 16px;}"
};
const data = fs.read(path.resolve(filePath));
inline(data, options)
.then(html => {
let outputFile = path.resolve(filePath);
fs.write(outputFile, html);
})
.catch(err => {
console.log(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment