-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.js
65 lines (51 loc) · 1.7 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
/* eslint-disable ember-suave/prefer-destructuring */
'use strict';
const path = require('path');
const Funnel = require('broccoli-funnel');
const MergeTrees = require('broccoli-merge-trees');
const map = require('broccoli-stew').map;
module.exports = {
name: require('./package').name,
included(app) {
this._super.included.apply(this, arguments);
// see: https://github.com/ember-cli/ember-cli/issues/3718
while (typeof app.import !== 'function' && app.app) {
app = app.app;
}
if (typeof app.import !== 'function') {
throw new Error('ember-hammertime is being used within another addon or engine '
+ 'and is having trouble registering itself to the parent application.');
}
app.import('vendor/hammer-time.js');
},
treeForVendor(vendorTree) {
let trees = [];
let hammertimeTree = new Funnel(path.dirname(require.resolve('hammer-timejs/hammer-time.js')), {
files: ['hammer-time.js']
});
hammertimeTree = map(hammertimeTree, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);
if (vendorTree !== undefined) {
trees.push(vendorTree);
}
trees.push(hammertimeTree);
return new MergeTrees(trees);
},
isDevelopingAddon() {
return false;
},
projectConfig() {
return this.project.config(process.env.EMBER_ENV);
},
setupPreprocessorRegistry(type, registry) {
let touchAction = require('./htmlbars-plugins/touch-action');
let config = this.projectConfig().EmberHammertime;
touchAction.setConfigValues(config);
registry.add('htmlbars-ast-plugin', {
name: 'touch-action',
plugin: touchAction.TouchActionSupport,
baseDir() {
return __dirname;
}
});
}
};