Skip to content

Commit

Permalink
Filtering container debug results based on module
Browse files Browse the repository at this point in the history
Don't return things from catalogEntriesByType that don't belong to your main app.
  • Loading branch information
ryanlabouve committed Dec 1, 2016
1 parent ffa7e2c commit bfaf81b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion addon/container-debug-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ if (typeof ContainerDebugAdapter !== 'undefined') {
for (let i = 0, l = moduleNames.length; i < l; i++) {
let key = moduleNames[i];

if(key.indexOf(type) !== -1 && key.indexOf('npm:') !== 0) {
if (this.startsWithModuleOrPodModulePrefix(key) && key.indexOf(type) !== -1) {
// Check if it's a pod module
var name = getPod(type, key, this.namespace.podModulePrefix || prefix);
if (!name) {
Expand All @@ -102,6 +102,16 @@ if (typeof ContainerDebugAdapter !== 'undefined') {
}
}
return types;
},

/**
@private
@method startsWithModuleOrPodModulePrefix
@param {string} moduleName Name of module being tested
@return {Boolean}
*/
startsWithModuleOrPodModulePrefix(moduleName) {
return moduleName.indexOf(this.namespace.modulePrefix) === 0 || moduleName.indexOf(this.namespace.podModulePrefix) === 0;
}
});
}
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/container-debug-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ test('Ignores browserify modules', function(assert) {
var models = containerDebugAdapter.catalogEntriesByType('model');
assert.equal(models.length, 0, 'Ignores the browserify modules');
});

test('Ignores modules that are not part of the main app', function(assert) {
assert.expect(1);
def('liquid/awesome/model');
def('liquid/models/awesome');
var models = containerDebugAdapter.catalogEntriesByType('model');
assert.equal(models.length, 0, 'Ignores packages not in the main app');
});

0 comments on commit bfaf81b

Please sign in to comment.