-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
60 lines (50 loc) · 1.49 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
/* eslint-env node */
'use strict';
var path = require('path');
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var stew = require('broccoli-stew');
const map = stew.map;
module.exports = {
name: 'ember-highlightjs-shim',
included(app, parentAddon) {
var target = (parentAddon || app);
this._super.included.apply(this, arguments);
this.importOption(target);
this.importCss(target);
this.importJs(target);
},
importOption(target) {
const addonENVConfig = target.project.config().highlightTheme || 'atom-one-dark';
this.theme = addonENVConfig;
},
importCss(target) {
let file = `vendor/highlightjs/${this.theme}.css`;
target.import(file);
},
importJs(target) {
target.import({
development: 'vendor/highlightjs/highlight.pack.js',
production: 'vendor/highlightjs/highlight.pack.min.js'
});
target.import('vendor/shims/highlight.js');
},
treeForVendor(vendorTree) {
let trees = [];
if (vendorTree) {
trees.push(vendorTree);
}
var hlCss = new Funnel(path.dirname(require.resolve('highlightjs')), {
srcDir: 'styles',
files: [this.theme + '.css'],
destDir: 'highlightjs'
});
trees.push(hlCss);
var hlJs = new Funnel(path.dirname(require.resolve('highlightjs')), {
files: ['highlight.pack.js', 'highlight.pack.min.js'],
destDir: 'highlightjs'
});
trees.push(hlJs);
return map(mergeTrees(trees), (content) => content);
},
};