Permalink
Browse files

Change default output directory

  • Loading branch information...
1 parent 27e7cf4 commit 8b0915b612f7fc9efc06eb4eceea7f3eb1382aff @kunklejr committed May 17, 2012
Showing with 13 additions and 12 deletions.
  1. +1 −1 bin/covershot
  2. +7 −6 lib/cli.js
  3. +5 −5 lib/covershot.js
  4. BIN lib/format/html/resources/cover_shot_logo.png
View
@@ -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
@@ -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
@@ -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 {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8b0915b

Please sign in to comment.