-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (40 loc) · 1.36 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
/* jshint node: true */
'use strict';
var path = require('path');
var Funnel = require('broccoli-funnel');
var compileSass = require('broccoli-sass');
module.exports = {
name: 'ember-ma-square',
treeForApp: function() {
return this.buildTree(this.root, ['component.js', 'library.js', 'helper.js']);
},
treeForTemplates: function() {
return this.buildTree(this.root, ['template.hbs']);
},
treeForAddon: function() {
var cssTree = compileSass([this.root], 'style.scss', 'style.css');
return this.buildTree(cssTree, ['style.css']);
},
buildTree: function(sourceTree, includedFiles) {
var addon = this;
return new Funnel(sourceTree, {
include: includedFiles,
getDestinationPath: function(relativePath) {
return addon.mapFile(relativePath);
}
});
},
mapFile: function(relativePath) {
if (relativePath === 'component.js') {
return path.join('components', this.name + '.js');
} else if (relativePath === 'library.js') {
return path.join('lib', this.name + '.js');
} else if (relativePath === 'helper.js') {
return path.join('helpers', this.name + '.js');
} else if (relativePath === 'template.hbs') {
return path.join('components', this.name + '.hbs');
} else if (relativePath === 'style.css') {
return path.join('addon/styles', this.name + '.css');
}
}
};