From d394962f5d6815290d10f2258660a93ec19427b5 Mon Sep 17 00:00:00 2001 From: Andrii Kostenko Date: Thu, 28 Feb 2013 18:31:06 +0200 Subject: [PATCH 1/4] support for different roots in buster config --- lib/extension.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/extension.js b/lib/extension.js index 3c9fde4..5fad493 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -3,14 +3,15 @@ var fs = require('fs'); var coverageHelpers = require('coverage-helpers'); var coverageExclusions = []; -function processor(resource, content) { +function processor(resource, content, rootPath) { for (var i = 0; i < coverageExclusions.length; i++) { if (resource.path.indexOf(coverageExclusions[i]) !== -1) { return content; } } var contentBuffer = new Buffer(content, resource.encoding); - var fullPath = path.join(process.cwd(), resource.path); + var fullPath = path.join(rootPath, resource.path); + console.log(fullPath); return coverageHelpers.instrument(contentBuffer, fullPath).toString(resource.encoding); } @@ -32,7 +33,9 @@ module.exports = { this.config_name = config.name; config.on('load:sources', function (resourceSet) { - resourceSet.addProcessor(processor); + resourceSet.addProcessor(function (resource, content) { + return processor(resource, content, resourceSet.rootPath) + }); }); config.on('load:framework', function (resourceSet) { From 0da825d233b50f0009610858d2239365165a6b8e Mon Sep 17 00:00:00 2001 From: Andrii Kostenko Date: Thu, 28 Feb 2013 19:00:42 +0200 Subject: [PATCH 2/4] removed debug --- lib/extension.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/extension.js b/lib/extension.js index 5fad493..f009d1f 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -11,7 +11,6 @@ function processor(resource, content, rootPath) { } var contentBuffer = new Buffer(content, resource.encoding); var fullPath = path.join(rootPath, resource.path); - console.log(fullPath); return coverageHelpers.instrument(contentBuffer, fullPath).toString(resource.encoding); } From aa2cb0016809995ff7d02d07ef7fb48224b6afab Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 14 May 2013 16:13:28 +0100 Subject: [PATCH 3/4] If the Buster config specifies a rootPath, apply it to the outputDirectory --- lib/extension.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/extension.js b/lib/extension.js index f009d1f..8206455 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -30,6 +30,7 @@ module.exports = { configure: function (config) { this.config_name = config.name; + this.outputDirectory = path.join(config.rootPath, this.outputDirectory); config.on('load:sources', function (resourceSet) { resourceSet.addProcessor(function (resource, content) { From 91bb2506cf5d830982f875c849b2d1be445e3407 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 15 May 2013 12:24:09 +0100 Subject: [PATCH 4/4] Fix support for configs without rootPath specified Fall back to the old behaviour including process.cwd() usage --- lib/extension.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/extension.js b/lib/extension.js index 8206455..e0e015c 100644 --- a/lib/extension.js +++ b/lib/extension.js @@ -4,6 +4,9 @@ var coverageHelpers = require('coverage-helpers'); var coverageExclusions = []; function processor(resource, content, rootPath) { + if (typeof rootPath === 'undefined') { + rootPath = process.cwd(); + } for (var i = 0; i < coverageExclusions.length; i++) { if (resource.path.indexOf(coverageExclusions[i]) !== -1) { return content; @@ -30,7 +33,9 @@ module.exports = { configure: function (config) { this.config_name = config.name; - this.outputDirectory = path.join(config.rootPath, this.outputDirectory); + if (typeof config.rootPath !== 'undefined') { + this.outputDirectory = path.join(config.rootPath, this.outputDirectory); + } config.on('load:sources', function (resourceSet) { resourceSet.addProcessor(function (resource, content) {