-
Notifications
You must be signed in to change notification settings - Fork 57
/
index.js
72 lines (57 loc) · 1.97 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
72
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const BroccoliMergeTrees = require('broccoli-merge-trees');
const fastbootTransform = require('fastboot-transform');
const resolve = require('resolve');
module.exports = {
name: 'ember-gestures',
included() {
this._super.included.apply(this, arguments);
let app;
// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
if (typeof this._findHost === 'function') {
app = this._findHost();
} else {
// Otherwise, we'll use this implementation borrowed from the _findHost()
// method in ember-cli.
let current = this;
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
}
app.import('vendor/hammerjs/hammer.js');
app.import('vendor/animation-frame/AnimationFrame.js');
},
treeForVendor(tree) {
let trees = [];
let hammerJs = fastbootTransform(new Funnel(this.pathBase('hammerjs'), {
files: ['hammer.js'],
destDir: 'hammerjs'
}));
let animationFrame = fastbootTransform(new Funnel(this.pathBase('animation-frame'), {
files: ['AnimationFrame.js'],
destDir: 'animation-frame'
}));
trees = trees.concat([hammerJs, animationFrame]);
if (tree) {
trees.push(tree);
}
return new BroccoliMergeTrees(trees);
},
/*
Rely on the `resolve` package to mimic node's resolve algorithm.
It finds the modules in a manner that works for npm 2.x,
3.x, and yarn in both the addon itself and projects that depend on this addon.
This is an edge case b/c some modules do not have a main
module we can require.resolve through node itself and similarily ember-cli
does not have such a hack for the same reason.
*/
pathBase(packageName) {
return path.dirname(resolve.sync(`${packageName}/package.json`, { basedir: __dirname }));
},
isDevelopingAddon() {
return false;
}
};