forked from willviles/ember-useragent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (48 loc) · 1.34 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
'use strict';
const BroccoliDebug = require('broccoli-debug');
const Funnel = require('broccoli-funnel');
const mergeTrees = require('broccoli-merge-trees');
const path = require('path');
const fastbootTransform = require('fastboot-transform');
module.exports = {
name: 'ember-useragent',
included(app) {
this.importDependencies(app);
return this._super.included.apply(this, arguments);
},
importDependencies(app) {
if (arguments.length < 1) {
throw new Error('Application instance must be passed to import');
}
app.import(this.treePaths.vendor + '/ua-parser-js/ua-parser.js');
app.import('vendor/shims/ua-parser-js.js', {
exports: {
['ua-parser-js']: ['default']
}
});
},
treeForVendor(vendorTree) {
let debugTree = BroccoliDebug.buildDebugCallback(this.name),
trees = [];
if (vendorTree) {
trees.push(
debugTree(vendorTree, 'vendorTree')
);
}
let js = fastbootTransform(
moduleToFunnel('ua-parser-js')
);
trees.push(
debugTree(js, 'js')
);
return mergeTrees(trees);
}
};
function moduleToFunnel(moduleName, destination) {
return new Funnel(resolveModulePath(moduleName), {
destDir: destination || moduleName
});
}
function resolveModulePath(moduleName) {
return path.dirname(require.resolve(moduleName));
}