Skip to content

Commit

Permalink
Added options object to set the coverage name when used with stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
davglass committed Aug 17, 2012
1 parent 7d6e647 commit 5776b19
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions nodejs-coverage/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ lists.some(function(item) {
exports.jar = jar;


var cover = function(item, charset, callback) {
var cover = function(item, options, callback) {
if (typeof charset === 'function') {
callback = charset;
charset = 'utf8';
callback = options;
options = { charset: 'utf8' };
}

getFile(item, function(err, file, rm) {
coverFile(file, charset, callback, rm);
getFile(item, options.name, function(err, file, rm) {
coverFile(file, options, callback, rm);
});
};

var getFile = function(str, callback) {
var getFile = function(str, name, callback) {
exists(str, function(y) {
if (y) {
callback(null, str);
} else {
//Write Temp File..
var tmpFile = path.join(__dirname, 'tmp-' + (new Date()).getTime() + '.' + (++idx));
var tmpFile = name || path.join(__dirname, 'tmp-' + (new Date()).getTime() + '.' + (++idx));
fs.writeFile(tmpFile, str, 'utf8', function(err) {
callback(null, tmpFile, true);
});
Expand All @@ -42,13 +42,13 @@ var getFile = function(str, callback) {
};


var coverFile = function(file, charset, callback, rm) {
var coverFile = function(file, options, callback, rm) {

var args = [
'-jar',
jar,
'--charset',
charset,
options.charset,
file
], buffer = '', errBuffer = '', child;

Expand Down

0 comments on commit 5776b19

Please sign in to comment.