Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to treeForAddonTestSupport #89

Merged
merged 3 commits into from
Apr 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
20 changes: 15 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint-env node */

const VersionChecker = require('ember-cli-version-checker');
const Funnel = require('broccoli-funnel');

module.exports = {
name: 'ember-test-selectors',
Expand Down Expand Up @@ -79,11 +80,20 @@ module.exports = {
}
},

treeForAddon() {
// remove our "addon" folder from the build if we're stripping test selectors
if (!this._stripTestSelectors) {
return this._super.treeForAddon.apply(this, arguments);
}
treeForAddonTestSupport(tree) {
// intentionally not calling _super here
// so that can have our `import`'s be
// import testSelector from 'ember-test-selectors';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. What tree would _super return?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can have a look. I just did the implementation based on example in #87.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_super would return same tree but with namespace including the sub folder -

destDir: /${this.moduleName()}/test-support

_super also returns already preprocessed js files.


let namespacedTree = new Funnel(tree, {
srcDir: '/',
destDir: `/${this.moduleName()}`,
annotation: `Addon#treeForTestSupport (${this.name})`,
});

return this.preprocessJs(namespacedTree, '/', this.name, {
registry: this.registry,
});
},

preprocessTree(type, tree) {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"test:strip": "STRIP_TEST_SELECTORS=true ember test"
},
"dependencies": {
"broccoli-funnel": "^1.1.0",
"broccoli-stew": "^1.4.0",
"ember-cli-babel": "^5.1.7",
"ember-cli-version-checker": "^1.2.0"
},
Expand Down