-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -347,6 +347,22 @@ Module.prototype._compile = function(content, filename) { | |
// remove shebang | ||
content = content.replace(/^\#\!.*/, ''); | ||
|
||
// add coverage | ||
if (process.cov) { | ||
var lines = content.split('\n'); | ||
|
||
if (lines.length > 0) { | ||
lines[0] = '__cov[__filename] = { 0: true}; ' + lines[0]; | ||
} | ||
|
||
for (var i = 0; i < lines.length; i++) { | ||
lines[i] = | ||
lines[i].replace(/;$/, '; __cov[__filename][' + i + '] = true;'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
anatoliychakkaev
|
||
} | ||
|
||
content = lines.join('\n'); | ||
} | ||
|
||
function require(path) { | ||
return Module._load(path, self); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,9 @@ | |
global.GLOBAL = global; | ||
global.root = global; | ||
global.Buffer = NativeModule.require('buffer').Buffer; | ||
if (process.cov) { | ||
global.__cov = {}; | ||
} | ||
}; | ||
|
||
startup.globalTimeouts = function() { | ||
|
@@ -343,6 +346,20 @@ | |
var path = NativeModule.require('path'); | ||
process.argv[0] = path.join(cwd, process.argv[0]); | ||
} | ||
|
||
if (process.cov) { | ||
process.on('exit', function() { | ||
This comment has been minimized.
Sorry, something went wrong.
ry
Author
|
||
var coverage = JSON.stringify(__cov); | ||
var path = NativeModule.require('path'); | ||
var fs = NativeModule.require('fs'); | ||
var filename = path.join(cwd, 'node-cov.json'); | ||
try { | ||
fs.unlinkSync(filename); | ||
} catch(e) { | ||
} | ||
fs.writeFileSync(filename, coverage); | ||
}); | ||
} | ||
}; | ||
|
||
// Below you find a minimal module system, which is used to load the node | ||
|
Interesting, is this how we'll get @isaacs back on the righteous path of using semicolons : )?