Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change default output directory

  • Loading branch information...
commit 8b0915b612f7fc9efc06eb4eceea7f3eb1382aff 1 parent 27e7cf4
@kunklejr authored
View
2  bin/covershot
@@ -18,7 +18,7 @@ var argv = optimist
})
.options('w', {
alias: 'write',
- default: path.join(process.cwd(), 'coverage'),
+ default: path.join(process.cwd(), 'covershot'),
describe: 'Directory to write output to.'
})
.options('v', {
View
13 lib/cli.js
@@ -55,8 +55,8 @@ function writeReports(data, formatters, write, callback) {
}, callback);
}
-function addJsMeterData(data, callback) {
- async.forEach(data.files, addJsMeterDataToFile, function (err) {
+function addJsMeterData(data, outputDir, callback) {
+ async.forEach(data.files, addJsMeterDataToFile.bind(this, outputDir), function (err) {
if (err) {
return callback(err);
}
@@ -65,8 +65,8 @@ function addJsMeterData(data, callback) {
});
}
-function addJsMeterDataToFile(file, callback) {
- var filename = path.join('./coverage/jsmeter/lib', file.filename.replace(/\.js$/, '.json'));
+function addJsMeterDataToFile(outputDir, file, callback) {
+ var filename = path.join(outputDir, 'jsmeter', 'lib', file.filename.replace(/\.js$/, '.json'));
fs.readFile(filename, 'utf8', function (err, data) {
if (err && err.toString().indexOf('ENOENT') >= 0) {
return callback();
@@ -95,6 +95,7 @@ exports.run = function (options, callback) {
options.map = options.map || 'json';
var mapper = require('./map/' + options.map);
var formatters = getFormatters(options.f);
+ var outputDir = options.write;
var files = options._;
if (files.length === 0) {
@@ -107,7 +108,7 @@ exports.run = function (options, callback) {
process.stdin.on('end', function () {
var data = buffers.join('');
data = mapper.map(data);
- addJsMeterData(data, function (err) {
+ addJsMeterData(data, outputDir, function (err) {
if (err) {
return callback(err);
}
@@ -135,7 +136,7 @@ exports.run = function (options, callback) {
}
results = results.map(function (buffer) {return mapper.map(buffer.toString()); });
var data = merge(results);
- addJsMeterData(data, function (err) {
+ addJsMeterData(data, outputDir, function (err) {
if (err) {
return callback(err);
}
View
10 lib/covershot.js
@@ -1,7 +1,10 @@
-var replacements = [];
+var path = require('path');
exports.format = require('./format');
exports.map = require('./map');
+exports.outputDir = path.join(process.cwd(), 'covershot');
+
+var replacements = [];
if (!global.top) {
global.top = {};
@@ -23,9 +26,6 @@ function getReplacement(path) {
return path;
}
-exports.format = require('./format');
-exports.map = require('./map');
-
exports.require = function (require, path) {
var instrumentedPath = getReplacement(path);
@@ -67,7 +67,7 @@ var writeCoverage = exports.writeCoverage = function () {
var path = require('path');
var mkdirp = require('mkdirp');
var mapper = require('./map/node-jscoverage');
- var dir = path.join(process.cwd(), 'coverage', 'data');
+ var dir = path.join(exports.outputDir, 'data');
var filename = path.join(dir, process.pid + '.json');
try {
View
BIN  lib/format/html/resources/cover_shot_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.