From 87f6d897adf3250745a115eb829832f2d328f1e6 Mon Sep 17 00:00:00 2001 From: John Towler Date: Mon, 10 Apr 2017 16:31:34 -0700 Subject: [PATCH 1/2] Added support for in-repo addons --- index.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 7904e6df..c34f4fbb 100644 --- a/index.js +++ b/index.js @@ -63,6 +63,18 @@ module.exports = { return new BroccoliMergeTrees([tree, instrumentedNode], { overwrite: true }); }, + setupPreprocessorRegistry: function() { + var codeCoverageAddon = this; + function iterateAddons(addons) { + addons.forEach(function(addon) { + if (addon.isDevelopingAddon && addon.isDevelopingAddon()) { + addon.addons.push(codeCoverageAddon); + } + }); + } + iterateAddons(this.project.addons); + }, + includedCommands: function () { return { 'coverage-merge': require('./lib/coverage-merge') @@ -145,6 +157,22 @@ module.exports = { return this._doesTemplateFileExist(relativePath); }, + /** + * Check if a file exists within an in-repo addon + * @param {String} relativePath - path to file + * @returns {Boolean} whether or not the file exists within an in-app addon + */ + _doesFileExistInCurrentProjectInRepoAddons: function(relativePath) { + relativePath = relativePath.split('/').splice(1, 0, 'addon').join('/'); + relativePath = path.join('lib', relativePath); + + if (this._existsSync(relativePath)) { + return true; + } + + return this._doesTemplateFileExist(relativePath); + }, + /** * Check if a template file exists within the current app/addon * Note: Template files are already compiled into JavaScript files so we must @@ -195,7 +223,8 @@ module.exports = { this._doesFileExistInDummyApp(relativePath) || this._doesFileExistInCurrentProjectApp(relativePath) || this._doesFileExistInCurrentProjectAddon(relativePath) || - this._doesFileExistInCurrentProjectAddonModule(relativePath) + this._doesFileExistInCurrentProjectAddonModule(relativePath) || + this._doesFileExistInCurrentProjectInRepoAddons(relativePath) ); return !fileExists; From 0d8f4dfb91358108e625a4a931a0b104e5a3e6f6 Mon Sep 17 00:00:00 2001 From: John Towler Date: Thu, 13 Apr 2017 16:32:35 -0700 Subject: [PATCH 2/2] Returning to infinite depth recursion, because it breaks our use case, and doesn't fix the testing issue. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index c34f4fbb..7f508334 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ module.exports = { if (addon.isDevelopingAddon && addon.isDevelopingAddon()) { addon.addons.push(codeCoverageAddon); } + iterateAddons(addon.addons); }); } iterateAddons(this.project.addons);