File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change 11const vstsCoverageStyles = require ( './index' ) . VstsCoverageStyles ;
22
33vstsCoverageStyles ( {
4- coverageDir : './test'
4+ coverageDir : './test' ,
5+ extraCss : '.test{color:red;}'
56} ) ;
Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ const cleanCSS = require('clean-css');
77var appRoot = require ( 'app-root-path' ) ;
88
99module . exports = function ( options ) {
10- if ( ! ( options && options . coverageDir ) )
10+ if ( ! ( options && options . coverageDir ) )
1111 throw new Error ( 'coverageDir param is required' ) ;
1212
1313 const defaultOpts = {
1414 coverageDir : './' ,
1515 pattern : '/**/*.html' ,
1616 fileEncoding : 'utf8' ,
17+ extraCss : '' ,
1718 minifyOptions : {
1819
1920 }
@@ -33,6 +34,10 @@ module.exports = function (options) {
3334
3435 let fileCache = { } ;
3536
37+ if ( opts . extraCss ) {
38+ opts . extraCss = new cleanCSS ( opts . minifyOptions ) . minify ( opts . extraCss ) . styles ;
39+ }
40+
3641 files . forEach ( ( file ) => {
3742 fs . readFile ( file , opts . fileEncoding , ( fileErr , data ) => {
3843 const $ = cheerio . load ( data ) ;
@@ -47,9 +52,15 @@ module.exports = function (options) {
4752
4853 $ ( '<style/>' ) . html ( fileCache [ resolvedHref ] ) . insertAfter ( jElem ) ;
4954 jElem . remove ( ) ;
50- fs . writeFile ( file , $ . html ( ) , ( ) => {
51- // console.log(file + ' written');
52- } ) ;
55+ } ) ;
56+
57+ if ( opts . extraCss ) {
58+ var customCssObj = $ ( '<style/>' ) . html ( opts . extraCss ) ;
59+ $ ( 'head' ) . append ( customCssObj ) ;
60+ }
61+
62+ fs . writeFile ( file , $ . html ( ) , ( ) => {
63+ // console.log(file + ' written');
5364 } ) ;
5465 } ) ;
5566 } ) ;
You can’t perform that action at this time.
0 commit comments