Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] checkModule and defaultCovIgnore shall work on Windows (MINGW) #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ var path = require('path');
var fs = require('fs');
var argv = require('optimist').argv;
var jscoverage = require('./jscoverage');

var escapeRe = require('escape-string-regexp');
var covInject = false;

var defaultCovIgnore = [
new RegExp('^' + process.cwd() + '/node_modules/'),
new RegExp('^' + process.cwd() + '/test/')
new RegExp('^' + escapeRe(path.join(process.cwd(),"node_modules/"))),
new RegExp('^' + escapeRe(path.join(process.cwd(),"test/")))
];
var covIgnore = defaultCovIgnore;

Expand Down Expand Up @@ -68,7 +69,7 @@ exports.setCovIgnore = function (ignore, bool) {
if (flagjsc && cachedModule && cachedModule.__coveraged__) {
return cachedModule.exports;
}
// console.log('jscoverage:', ff, 'cov', flagjsc, 'inject', needinject);

var module = new Module(filename, this);
try {
module.filename = filename;
Expand Down Expand Up @@ -138,17 +139,19 @@ exports.setCovIgnore = function (ignore, bool) {
})();

function checkModule(module) {
// native module
if (!/\//.test(module)) {
// native module does not contain / (or \ on windows)
if (!/[\/\\]/.test(module)) {
return false;
}

// modules in node_modules
var flagIgnore = false;
covIgnore.forEach(function (v) {

if (v.test(module)) {
flagIgnore = true;
}

});
return !flagIgnore;
}
Expand Down
30 changes: 17 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
"test": "./node_modules/mocha/bin/_mocha -t 60000 -r ./index.js -R spec --covinject true test/"
},
"engines": {
"node" : ">=0.8"
"node": ">=0.8"
},
"dependencies" : {
"uglify-js" : "2.4.15",
"optimist" : "0.3.1",
"xfs" : "0.1.8",
"ejs": "1.0.0",
"dependencies": {
"coffee-script": "*",
"debug": "1.0.3",
"coffee-script": "*"
"ejs": "1.0.0",
"escape-string-regexp": "^1.0.2",
"optimist": "0.3.1",
"uglify-js": "2.4.15",
"xfs": "0.1.8"
},
"devDependencies" : {
"mocha" : "*",
"expect.js" : "*",
"xfs" : "*"
"devDependencies": {
"mocha": "*",
"expect.js": "*",
"xfs": "*"
},
"repository": {
"type": "git",
Expand All @@ -38,8 +39,11 @@
"tool"
],
"author": "fish <zhengxinlin@gmail.com>, kate.sf <kate.sf@taobao.com>",
"contributors":[
{ "name": "christineRR", "email": "rongkunli1215@gmail.com" }
"contributors": [
{
"name": "christineRR",
"email": "rongkunli1215@gmail.com"
}
],
"license": "MIT"
}