Browse files

update JSCover to v0.1.1

  • Loading branch information...
1 parent 544a4cc commit 094cba396d4f5505e3d32740599a71007f7b5ad1 @fengmk2 fengmk2 committed Dec 11, 2012
Showing with 17 additions and 6 deletions.
  1. BIN bin/JSCover-all.jar
  2. +4 −1 lib/jscover.js
  3. +1 −0 package.json
  4. +7 −4 test/jscover.test.js
  5. +5 −1 test/lib/subdir/foo.js
View
BIN bin/JSCover-all.jar
Binary file not shown.
View
5 lib/jscover.js
@@ -10,6 +10,7 @@
* Module dependencies.
*/
+var debug = require('debug')('jscover');
var exec = require('child_process').exec;
var path = require('path');
var ndir = require('ndir');
@@ -43,6 +44,7 @@ module.exports = function jscover(source, target, options, callback) {
cmd += ' --exclude=node_modules --exclude=.git/ --exclude=.svn/';
cmd += ' --exclude="' + tmpTarget + '" --exclude="' + target + '"';
cmd += ' "' + source + '" "' + tmpTarget + '"';
+ debug(cmd);
var child = exec(cmd, function (err, stdout, stderr) {
var output = '';
if (stdout) {
@@ -52,10 +54,11 @@ module.exports = function jscover(source, target, options, callback) {
output += stderr;
if (!err) {
err = new Error(stderr.trim());
- err.name = 'JSCoverError';
}
+ err.name = 'JSCover' + err.name;
}
if (err) {
+ debug(err, stderr);
return callback(err, output);
}
View
1 package.json
@@ -14,6 +14,7 @@
},
"dependencies": {
"fs-extra": "0.3.1",
+ "debug": "0.7.0",
"ndir": "0.1.5"
},
"devDependencies": {
View
11 test/jscover.test.js
@@ -52,7 +52,7 @@ describe('jscover.test.js', function () {
jscover('', null, {}, function (err) {
should.exist(err);
err.name.should.equal('JSCoverError');
- err.message.should.equal("Source directory '' is invalid");
+ err.message.trim().should.equal("Command failed: Source directory '' is invalid");
done();
});
});
@@ -61,7 +61,7 @@ describe('jscover.test.js', function () {
jscover('a', 'b', {}, function (err) {
should.exist(err);
err.name.should.equal('JSCoverError');
- err.message.should.equal("Source directory 'a' is invalid");
+ err.message.trim().should.equal("Command failed: Source directory 'a' is invalid");
done();
});
});
@@ -74,8 +74,11 @@ describe('jscover.test.js', function () {
should.not.exist(output);
var regexp = fs.readFileSync(path.join(source, 'regexp.js'), 'utf8');
fs.readFileSync(path.join(target, 'regexp.js'), 'utf8').should.include(regexp);
- var targetFoo = path.join(target, 'subdir', 'foo');
- require(path.join(source, 'subdir', 'foo')).hello.should.equal(require(targetFoo).hello);
+ var targetFoo = require(path.join(target, 'subdir', 'foo'));
+ var sourceFoo = require(path.join(source, 'subdir', 'foo'));
+ for (var k in sourceFoo) {
+ sourceFoo[k].should.equal(targetFoo[k]);
+ }
done();
});
});
View
6 test/lib/subdir/foo.js
@@ -1 +1,5 @@
-exports.hello = '你好,Hello world';
+exports.hello = '你好,Hello world';
+exports.hexNumber = 0x12;
+exports.count = 16;
+
+exports.hexNumber2 = 0xff;

0 comments on commit 094cba3

Please sign in to comment.