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