Fix test-coverage.js script
Fix test-coverage by only replacing the last occurence of `/src/` when deriving the instrumented file path from the original file path.
This commit is contained in:
@@ -139,7 +139,15 @@ var foundAllJavaScriptSourceFiles = function(err, files) {
|
|||||||
files.forEach(function(file) {
|
files.forEach(function(file) {
|
||||||
cnt++;
|
cnt++;
|
||||||
var content = fs.readFileSync(file, 'utf-8');
|
var content = fs.readFileSync(file, 'utf-8');
|
||||||
var outfile = file.replace(/\/src\//, '/src-instrumented/');
|
// derive output file name from input file name, by replacing the *last*
|
||||||
|
// occurence of /src/ by /src-instrumented/
|
||||||
|
var re = new RegExp('/src/', 'g');
|
||||||
|
var m, match;
|
||||||
|
while ((m = re.exec(file)) !== null) {
|
||||||
|
match = m;
|
||||||
|
}
|
||||||
|
var outfile = file.substr(0, match.index) + '/src-instrumented/' +
|
||||||
|
file.substr(match.index + '/src/'.length);
|
||||||
var instrumented = instrumenter.instrumentSync(content, file);
|
var instrumented = instrumenter.instrumentSync(content, file);
|
||||||
fs.writeFileSync(outfile, instrumented);
|
fs.writeFileSync(outfile, instrumented);
|
||||||
if (cnt % 10 === 0) {
|
if (cnt % 10 === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user