forked from ember-animation/liquid-fire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (55 loc) · 1.69 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
61
62
63
64
65
66
67
68
69
70
71
/* jshint node: true */
'use strict';
var fs = require('fs');
var path = require('path');
var es3SafeRecast = require('broccoli-es3-safe-recast');
module.exports = {
name: 'Liquid Fire',
init: function() {
this.treePaths.app = 'app-addon';
this.treePaths.templates = 'app-addon/templates';
this.treePaths.vendor = 'vendor-addon';
makeBackwardCompatible(this);
},
treeFor: function(name) {
this._requireBuildPackages();
var treePath = path.join(this.root, this.treePaths[name]);
var tree;
if (fs.existsSync(treePath)) {
tree = this.treeGenerator(treePath);
if(name === 'vendor') {
var velocityPath = path.dirname(require.resolve('velocity-animate'));
var velocityTree = this.pickFiles(this.treeGenerator(velocityPath), {
srcDir: '/',
destDir: 'velocity'
});
tree = this.mergeTrees([es3SafeRecast(tree), velocityTree]);
}
return tree;
}
},
included: function(app) {
app.import('vendor/velocity/jquery.velocity.js');
app.import('vendor/liquid-fire/liquid-fire.css');
},
config: function() {
// prevent `config/environment.js` from being used
}
};
function makeBackwardCompatible(module) {
module.root = module.root || 'node_modules/liquid-fire';
if (!module.treeGenerator) {
module.treeGenerator = function(dir) {
return {
read: function() { return dir; },
cleanup: function() { }
};
};
}
if (!module._requireBuildPackages) {
module._requireBuildPackages = function(){
this.pickFiles = require('broccoli-static-compiler');
this.mergeTrees = require("broccoli-merge-trees");
};
}
}