forked from chrislopresto/ember-freestyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (43 loc) · 1.33 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
'use strict';
var mergeTrees = require('broccoli-merge-trees');
var fs = require('fs');
var flatiron = require('broccoli-flatiron');
var freestyleUsageSnippetFinder = require('./freestyle-usage-snippet-finder');
module.exports = {
name: 'ember-freestyle',
treeForApp: function(tree) {
var treesToMerge = [tree];
var self = this;
var snippets = mergeTrees(this.snippetPaths().filter(function(path) {
return fs.existsSync(path);
}));
snippets = mergeTrees(this.snippetSearchPaths().map(function(path) {
return freestyleUsageSnippetFinder(path, self.ui);
}).concat(snippets));
snippets = flatiron(snippets, {
outputFile: 'freestyle-snippets.js'
});
treesToMerge.push(snippets);
return mergeTrees(treesToMerge);
},
snippetPaths: function() {
if (this.app) {
var freestyleOptions = this.app.options.freestyle || {};
return freestyleOptions.snippetPaths || ['snippets'];
}
return ['snippets'];
},
snippetSearchPaths: function() {
if (this.app) {
var freestyleOptions = this.app.options.freestyle || {};
return freestyleOptions.snippetSearchPaths || ['app'];
}
return ['app'];
},
included: function(/*app, parentAddon*/) {
this._super.included.apply(this, arguments);
},
isDevelopingAddon: function() {
return false;
}
};