forked from johno/ember-remarkable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (48 loc) · 1.55 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
'use strict';
var path = require('path');
module.exports = {
name: 'ember-remarkable',
blueprintsPath: function() {
return path.join(__dirname, 'blueprints');
},
config: function(/*environment, appConfig*/) {
return {
remarkable: {
excludeHighlightJs: false
}
}
},
included: function(app) {
this._super.included.apply(this, arguments);
var bowerDirectory = this.project.bowerDirectory;
var importContext;
if (this.import) { // support for ember-cli >= 2.7
importContext = this;
} else { // addon support for ember-cli < 2.7
importContext = this._findHostForLegacyEmberCLI();
}
var env = app.env;
var config = this.project.config(env || 'development');
var excludeHighlightJs = config.remarkable.excludeHighlightJs;
importContext.import(bowerDirectory + '/remarkable/dist/remarkable.js');
if (!excludeHighlightJs) {
importContext.import(bowerDirectory + '/highlightjs/highlight.pack.js');
}
importContext.import('vendor/ember-remarkable/shim.js', {
type: 'vendor',
exports: { 'remarkable': ['default'] }
});
},
// included from https://git.io/v6F7n
// not needed for ember-cli > 2.7
_findHostForLegacyEmberCLI: function() {
var current = this;
var app;
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
}
};