app/util.js
/**
 * Writes a new _report.html file from the jsonData.
 * @param jsonData combined.json
 * @param baseName
 * @param options
 */
Writes a new _report.html file from the jsonData.
Writes a new _report . html file from the jsonData .
function addHTMLReport(jsonData, baseName, options){
    var basePath = path.dirname(baseName),
        htmlFile = path.join(basePath, options.docName),
        jsFile = path.join(basePath, 'app.js'),
        htmlInFile = path.join(__dirname, 'lib', 'index.html'),
        jsTemplate = path.join(__dirname, 'lib', 'app.js'),
        streamJs,
        streamHtml,
        cssLink = path.join('assets', 'bootstrap.css');
    try {
        if (options.cssOverrideFile) {
            cssLink = options.cssOverrideFile;
        }
        fse.copySync(path.join(__dirname, 'lib', 'assets'), path.join(basePath, 'assets'));
        fse.copySync(path.join(__dirname, 'lib', 'fonts'), path.join(basePath, 'fonts'));
        streamHtml = fs.createWriteStream(htmlFile);
        streamHtml.write(
            fs.readFileSync(htmlInFile)
                .toString()
                .replace('<!-- Here will be CSS placed -->', '<link rel="stylesheet" href="'+cssLink+'">')
                .replace('<!-- Here goes title -->', options.docTitle)
        );
        streamHtml.end();
        streamJs = fs.createWriteStream(jsFile);
        streamJs.write(
            fs.readFileSync(jsTemplate)
                .toString()
                .replace('\'<Results Replacement>\'', JSON.stringify(jsonData, null, 4))
                .replace('\'<Sort Function Replacement>\'', options.sortFunction.toString())
        );
        streamJs.end();
    } catch(e) {
        console.error(e);
        console.error('Could not save combined.js for data: ' + jsonData);
    }
}
function addHTMLReport ( jsonData , baseName , options ) { var basePath = path . dirname ( baseName ) , htmlFile = path . join ( basePath , options . docName ) , jsFile = path . join ( basePath , 'app.js' ) , htmlInFile = path . join ( __dirname , 'lib' , 'index.html' ) , jsTemplate = path . join ( __dirname , 'lib' , 'app.js' ) , streamJs , streamHtml , cssLink = path . join ( 'assets' , 'bootstrap.css' ) ; try { if ( options . cssOverrideFile ) { cssLink = options . cssOverrideFile ; } fse . copySync ( path . join ( __dirname , 'lib' , 'assets' ) , path . join ( basePath , 'assets' ) ) ; fse . copySync ( path . join ( __dirname , 'lib' , 'fonts' ) , path . join ( basePath , 'fonts' ) ) ; streamHtml = fs . createWriteStream ( htmlFile ) ; streamHtml . write ( fs . readFileSync ( htmlInFile ) . toString ( ) . replace ( '<!-- Here will be CSS placed -->' , '<link rel="stylesheet" href="' + cssLink + '">' ) . replace ( '<!-- Here goes title -->' , options . docTitle ) ) ; streamHtml . end ( ) ; streamJs = fs . createWriteStream ( jsFile ) ; streamJs . write ( fs . readFileSync ( jsTemplate ) . toString ( ) . replace ( '\'<Results Replacement>\'' , JSON . stringify ( jsonData , null , 4 ) ) . replace ( '\'<Sort Function Replacement>\'' , options . sortFunction . toString ( ) ) ) ; streamJs . end ( ) ; } catch ( e ) { console . error ( e ) ; console . error ( 'Could not save combined.js for data: ' + jsonData ) ; } }
Writes a new _report.html file from the jsonData.
Writes a new _report . html file from the jsonData .
// Output files // Input files //copy assets //copy bootstrap fonts // Construct index.html // Construct app.js