forked from knownasilya/ember-toastr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (43 loc) · 1.23 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
/* jshint node: true */
'use strict';
var Funnel = require('broccoli-funnel');
var MergeTrees = require('broccoli-merge-trees');
var path = require('path');
module.exports = {
name: 'ember-toastr',
included: function() {
this._super.included.apply(this, arguments);
this._ensureThisImport();
this.import('vendor/toastr/toastr.js');
this.import('vendor/toastr/build/toastr.css');
},
treeForVendor: function(vendorTree){
var toastrPath = path.dirname(require.resolve('toastr'));
var trees = [];
if(vendorTree){
trees.push(vendorTree);
}
var toastrTree = new Funnel(toastrPath, {
include: ['toastr.js', 'build/toastr.*'],
destDir: 'toastr',
});
trees.push(toastrTree);
return new MergeTrees(trees, { overwrite: true });
},
_ensureThisImport: function() {
if (!this.import) {
this._findHost = function findHostShim() {
var current = this;
var app;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
this.import = function importShim(asset, options) {
var app = this._findHost();
app.import(asset, options);
};
}
}
};