Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
closes #59 dont throw if optional module is not installed, print an e…
…rror if one is trying to use it.
  • Loading branch information
kof committed Sep 26, 2012
1 parent ca21cb9 commit 333d890
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
20 changes: 18 additions & 2 deletions lib/coverage.js
@@ -1,5 +1,12 @@
var bunker = require('bunker'),
fs = require('fs');
var fs = require('fs'),
util = require('util'),
_ = require('underscore'),
colors = require('colors'),
bunker;

try {
bunker = require('bunker');
} catch (err) {}

exports.instrument = function(path) {
var src = fs.readFileSync(path, 'utf-8'),
Expand All @@ -18,3 +25,12 @@ exports.restore = function(path) {
}

};

if (!bunker) {
_.each(exports, function(fn, name) {
exports[name] = function() {
util.error('Module "bunker" is not installed.'.red);
process.exit(1);
};
});
}
2 changes: 1 addition & 1 deletion lib/testrunner.js
Expand Up @@ -158,7 +158,7 @@ exports.run = function(files, callback) {
}

if (opts.coverage) {
converage.instrument(opts.code);
coverage.instrument(opts.code);
} else {
runOne(opts, finished);
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "qunit",
"description": "QUnit testing framework for nodejs",
"version": "0.5.9",
"version": "0.5.10",
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
"contributors": [
{"name": "Jonathan Buchanan"},
Expand All @@ -21,7 +21,8 @@
"underscore": "1.3.3",
"argsparser": "0.0.6",
"cli-table": "0.0.2",
"tracejs": "0.1.4"
"tracejs": "0.1.4",
"colors": "0.6.0"
},
"devDependencies": {
"chainer": "0.0.5",
Expand Down

0 comments on commit 333d890

Please sign in to comment.