UNPKG

jscover-shim

Version:

A lightweight shim between node and jscover-bin.

36 lines (26 loc) 724 B
var path = require('path'); var exec = require('child_process').exec; var jscoverPath = process.env.JSCOVER || require.resolve('jscover-bin'); var jscoverCommand = ['java -jar', jscoverPath].join(' '); module.exports = function jscover(options, callback) { var cmd = jscoverCommand; // Add in the options options = options || []; if (options && options.length > 0) { cmd += ' ' + options.join(' '); } // Execute the command exec(cmd, function (err, stdout, stderr) { var output = ''; if (stdout) { output += stdout; } if (stderr) { output += stderr; } if (err) { return callback(cmd, output, err); } return callback(cmd, output, null); }); };