Skip to content

Commit

Permalink
setup JS preprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoow committed Dec 2, 2016
1 parent 17225c6 commit 0cc827d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
var StripTestSelectorsTransform = require('./strip-test-selectors');
var StripDataTestAttributesProcessor = require('./strip-data-test-attributes');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
Expand All @@ -19,5 +20,10 @@ module.exports = function(defaults) {
baseDir: function() { return __dirname; }
});

// add the StripDataTestAttributesProcessor to the registry, so the dummy app has
// it added in the JS build pipeline: all data-test-* attributes are
// therefore stripped
app.registry.add('js', new StripDataTestAttributesProcessor());

return app.toTree();
};
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ module.exports = {

if (_includes(environments, registry.app.env)) {
var StripTestSelectorsTransform = require('./strip-test-selectors');

registry.add('htmlbars-ast-plugin', {
name: 'strip-test-selectors',
plugin: StripTestSelectorsTransform,
baseDir: function() { return __dirname; }
});

var StripDataTestAttributesProcessor = require('./strip-data-test-attributes');
registry.add('js', new StripDataTestAttributesProcessor());
}
}
};
11 changes: 11 additions & 0 deletions strip-data-test-attributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function StripDataTestAttributesProcessor(options) {
this.name = 'ember-cli-anything-to-js';
this.options = options || {};
}

StripDataTestAttributesProcessor.prototype.toTree = function(tree, inputPath, outputPath) {
console.log('doing here');
return tree;
};

module.exports = StripDataTestAttributesProcessor;

0 comments on commit 0cc827d

Please sign in to comment.