forked from pzuraq/liquid-tether
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (44 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
/*jshint node: true */
'use strict';
var path = require('path');
var mergeTrees = require('broccoli-merge-trees');
var Funnel = require('broccoli-funnel');
module.exports = {
name: 'liquid-tether',
init: function() {
if (this._super.init) {
this._super.init.apply(this, arguments);
}
// Shim this.import for Engines support
if (!this.import) {
// Shim from https://github.com/ember-cli/ember-cli/blob/5d64cfbf1276cf1e3eb88761df4546c891b5efa6/lib/models/addon.js#L387
this._findHost = function findHostShim() {
var current = this;
var app;
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
// Shim from https://github.com/ember-cli/ember-cli/blob/5d64cfbf1276cf1e3eb88761df4546c891b5efa6/lib/models/addon.js#L443
this.import = function importShim(asset, options) {
var app = this._findHost();
app.import(asset, options);
};
}
},
treeForVendor: function(tree) {
var tetherPath = path.dirname(require.resolve('tether'));
var tetherTree = new Funnel(this.treeGenerator(tetherPath), {
srcDir: '/',
destDir: 'tether'
});
return mergeTrees([tree, tetherTree]);
},
included: function(app) {
this._super.included(app);
this.import('vendor/tether/tether.js');
}
};