-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (42 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
/* eslint-env node */
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
module.exports = {
name: require('./package').name,
included (app) {
this.app = app;
this.settings = {};
this.settings = Object.assign(this.settings, app.options.presentationTarget);
if (typeof this.settings.enabled === 'undefined') {
this.settings.enabled = typeof this.settings.target !== 'undefined';
}
return this._super.included.apply(this, arguments);
},
preprocessTree(type, tree) {
if (type !== 'template' || !this.settings.enabled) {
return tree;
}
let nodes = [tree];
let targetTemplates = new Funnel(this.app.trees.app, {
srcDir: `templates/${this.settings.target}`,
destDir: `${this.app.name}/templates`,
annotation: `Classic Templates (${this.settings.target})`
});
nodes.push(targetTemplates);
if (typeof this.settings.common !== 'undefined') {
let commonTemplates = new Funnel(this.app.trees.app, {
srcDir: `templates/${this.settings.common}`,
destDir: `${this.app.name}/templates`,
annotation: `Classic Templates (${this.settings.common})`
});
nodes.push(commonTemplates);
}
let merged = mergeTrees(nodes, {
overwrite: true,
description: 'Templates',
annotation: 'Templates'
});
return merged;
}
};