-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathindex.js
60 lines (45 loc) · 1.52 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';
var path = require('path');
var Funnel = require('broccoli-funnel'); // eslint-disable-line
var mergeTrees = require('broccoli-merge-trees'); // eslint-disable-line
var map = require('broccoli-stew').map; // eslint-disable-line
var defaults = {
assetPath: 'vendor'
};
module.exports = {
name: 'ember-spectrum-color-picker',
included: function(app) {
this._super.included(app);
var target = this._findApp(app);
var options = (target && target.project.config(target.env)['emberSpectrumColorPicker']) || {};
var assetPath = options.assetPath || defaults.assetPath;
target.import(path.join(assetPath, 'spectrum.js'));
if (options.includeStyles) {
target.import(path.join(assetPath, 'spectrum.css'));
}
},
treeForVendor(vendorTree) {
var dir = path.dirname(require.resolve('spectrum-colorpicker'));
var spectrumJsTree = new Funnel(dir, {
files: ['spectrum.js']
});
var spectrumCssTree = new Funnel(dir, {
files: ['spectrum.css']
});
spectrumJsTree = map(spectrumJsTree, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
var spectrumTree = mergeTrees([spectrumJsTree, spectrumCssTree]);
return vendorTree ? mergeTrees([vendorTree, spectrumTree]) : spectrumTree;
},
_findApp: function(hostApp) {
var app = this.app || hostApp;
var parent = this.parent;
while (parent.parent) {
if (parent.app) {
app = parent.app;
break;
}
parent = parent.parent;
}
return app;
},
};