ember-cli-ajh
Version:
Command line tool for developing ambitious ember.js apps
41 lines (32 loc) • 1.07 kB
JavaScript
;
var fs = require('fs');
var Plugin = require('broccoli-plugin');
var mergeTrees = require('broccoli-merge-trees');
var path = require('path');
AddCustomFile.prototype = Object.create(Plugin.prototype);
AddCustomFile.prototype.constructor = AddCustomFile;
function AddCustomFile(inputNodes, options) {
this.path = options.path;
Plugin.call(this, inputNodes);
}
AddCustomFile.prototype.build = function() {
var outPath = path.join(this.outputPath, this.path);
fs.mkdirSync(path.dirname(outPath));
fs.writeFileSync(outPath, '// File for test tree imported and added via postprocessTree()');
};
var customTestFilePath = 'my-custom-test-assets/test-dependency.js';
module.exports = {
name: 'Ember Test Addon',
included: function included(app) {
this._super.included(app);
app.import(customTestFilePath, { type: 'test' });
},
postprocessTree: function(type, tree){
if (type === 'test') {
return mergeTrees([tree, new AddCustomFile([tree], {
path: customTestFilePath
})]);
}
return tree;
}
};