From 6db86c40d32eb403a62e1e79d4199f1123f87609 Mon Sep 17 00:00:00 2001 From: Calvin Mann Date: Thu, 28 Jan 2016 21:28:33 +0100 Subject: [PATCH 1/4] Added the ability to read sources in from the buster-istanbul config (To prevent auto loading of instrumented sources) --- lib/buster-istanbul.js | 27 ++++++++++++++++++++++----- package.json | 8 ++++---- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/buster-istanbul.js b/lib/buster-istanbul.js index 79940ba..72d3a41 100644 --- a/lib/buster-istanbul.js +++ b/lib/buster-istanbul.js @@ -68,15 +68,32 @@ var setup = { coverage.hookRequire(); if (instrument === false) return; group.on('load:sources', function(rs){ - var rootPath = rs.rootPath - rs.forEach(function(resource){ - var resourcePath = resource.path.replace(/\//, ''); - var excluded = isExcluded(resourcePath, excludes); + var rootPath = rs.rootPath, + additional = group.config['buster-istanbul'].sources; + if (Array.isArray(additional)) { + additional.forEach(processAdditional); + } + rs.forEach(processResource); + function processAdditional(a) { + glob(a, function (er, files) { + if (er) { + throw er; + } else { + files.forEach(processResource); + } + }); + } + function processResource(resource) { + if (typeof resource === 'object') { + resource = resource.path; + } + var resourcePath = resource.replace(/^\//, ''); + var excluded = isExcluded(resourcePath, excludes); if (!excluded) { coverage.addInstrumentCandidate(path.join(rootPath, resourcePath)); } - }); + } }); }, diff --git a/package.json b/package.json index 1a78fcb..c03079d 100644 --- a/package.json +++ b/package.json @@ -2,22 +2,22 @@ "name": "buster-istanbul", "description": "buster extension for istanbul code coverage.", "version": "0.1.15", - "homepage": "https://github.com/englishtown/buster-istanbul", + "homepage": "https://github.com/major-mann/buster-istanbul", "author": { "name": "kates", "email": "katesgasis@gmail.com" }, "repository": { "type": "git", - "url": "git://github.com/englishtown/buster-istanbul.git" + "url": "git@github.com:major-mann/buster-istanbul.git" }, "bugs": { - "url": "https://github.com/englishtown/buster-istanbul/issues" + "url": "https://github.com/major-mann/buster-istanbul/issues" }, "licenses": [ { "type": "MIT", - "url": "https://github.com/englishtown/buster-istanbul/blob/master/LICENSE-MIT" + "url": "https://github.com/major-mann/buster-istanbul/blob/master/LICENSE-MIT" } ], "main": "lib/buster-istanbul", From fbee732b530e0a1a54509d21a4539433da7bc70e Mon Sep 17 00:00:00 2001 From: Calvin Mann Date: Thu, 28 Jan 2016 21:30:58 +0100 Subject: [PATCH 2/4] Added details of changes to readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5b2b85c..8226c07 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ You will need to handle this yourself. Defaults to `true`. This can be helpful if your sources include non-js files that needed to be excluded, such as .html or .json files. Consult [node-glob](https://github.com/isaacs/node-glob) for more information on globs. +`sources` is an array of glob paths that will be instrumented in addition to paths supplied in global sources. This +allows paths to be instrumented, but not automatically loaded. Note: This only has effect in a node environment + Write your buster test as usual. Example project: [buster-istanbul-demo](https://github.com/kates/buster-istanbul-demo) From bfd68f874b10634789eec22b9f4b3d0418b9c5a1 Mon Sep 17 00:00:00 2001 From: Calvin Mann Date: Thu, 28 Jan 2016 21:47:43 +0100 Subject: [PATCH 3/4] Bumped version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c03079d..8899ecc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "buster-istanbul", "description": "buster extension for istanbul code coverage.", - "version": "0.1.15", + "version": "0.1.16", "homepage": "https://github.com/major-mann/buster-istanbul", "author": { "name": "kates", From 5c0c6cb26336fad1cadb9b2321e206696f4c7084 Mon Sep 17 00:00:00 2001 From: Calvin Mann Date: Thu, 28 Jan 2016 22:25:32 +0100 Subject: [PATCH 4/4] Reverted package.json to original except for version bump --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8899ecc..5bfe328 100644 --- a/package.json +++ b/package.json @@ -2,22 +2,22 @@ "name": "buster-istanbul", "description": "buster extension for istanbul code coverage.", "version": "0.1.16", - "homepage": "https://github.com/major-mann/buster-istanbul", + "homepage": "https://github.com/englishtown/buster-istanbul", "author": { "name": "kates", "email": "katesgasis@gmail.com" }, "repository": { "type": "git", - "url": "git@github.com:major-mann/buster-istanbul.git" + "url": "git://github.com/englishtown/buster-istanbul.git" }, "bugs": { - "url": "https://github.com/major-mann/buster-istanbul/issues" + "url": "https://github.com/englishtown/buster-istanbul/issues" }, "licenses": [ { "type": "MIT", - "url": "https://github.com/major-mann/buster-istanbul/blob/master/LICENSE-MIT" + "url": "https://github.com/englishtown/buster-istanbul/blob/master/LICENSE-MIT" } ], "main": "lib/buster-istanbul",