From bc1087b47e46ec5b4e1b8b4f2fa7eb3af35a3b10 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 95a02edb..c006432c 100644 --- a/index.js +++ b/index.js @@ -61,6 +61,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') @@ -143,6 +155,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 @@ -193,7 +221,8 @@ module.exports = { this._doesFileExistInDummyApp(relativePath) || this._doesFileExistInCurrentProjectApp(relativePath) || this._doesFileExistInCurrentProjectAddon(relativePath) || - this._doesFileExistInCurrentProjectAddonModule(relativePath) + this._doesFileExistInCurrentProjectAddonModule(relativePath) || + this._doesFileExistInCurrentProjectInRepoAddons(relativePath) ); return !fileExists; From 62601d89d3eaaafb626f0f9df1259092a191bc57 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 c006432c..859915f6 100644 --- a/index.js +++ b/index.js @@ -68,6 +68,7 @@ module.exports = { if (addon.isDevelopingAddon && addon.isDevelopingAddon()) { addon.addons.push(codeCoverageAddon); } + iterateAddons(addon.addons); }); } iterateAddons(this.project.addons);