-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.js
More file actions
78 lines (63 loc) · 3.09 KB
/
index.js
File metadata and controls
78 lines (63 loc) · 3.09 KB
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
73
74
75
76
77
78
var fs = require('fs');
var path = require('path');
var path_join = function(){
// fix path with windows back slash with path_join
return path.join.apply(this, arguments).replace(/\\/g, '/');
};
module.exports = {
name: 'ember-cli-bootstrap-sass',
included: function included(app) {
this.app = app;
var emberCLIVersion = app.project.emberCLIVersion();
if (emberCLIVersion < '0.0.41') {
throw new Error('ember-cli-bootstrap-sass requires ember-cli version 0.0.41 or greater.\n');
}
var options = app.options['ember-cli-bootstrap-sass'] || {};
var ibs_opts = options.importBootstrapJS
var modulePath = path.relative(app.project.root, __dirname);
var bootstrapPath = 'vendor/bootstrap-sass-official/assets';
var emberBsPath = 'vendor/ember-addons.bs_for_ember/dist';
var javascriptsPath = path_join(emberBsPath, 'js');
switch (options.components) {
case true:
var jsFiles = fs.readdirSync(path_join(modulePath, javascriptsPath));
break
case false:
var jsFiles = false;
break
default:
var jsFiles = options.components ? options.components : fs.readdirSync(path_join(modulePath, javascriptsPath));
break
}
// Non-destructively add paths to SASS
// Non-destructively add paths to SASS
app.options.sassOptions = app.options.sassOptions || {}
app.options.sassOptions.includePaths = app.options.sassOptions.includePaths || []
app.options.sassOptions.includePaths.push(path_join(modulePath, bootstrapPath, 'stylesheets'));
app.options.sassOptions.includePaths.push(path_join(modulePath, bootstrapPath, 'stylesheets/bootstrap'));
app.options.sassOptions.includePaths.push(path_join(modulePath, bootstrapPath, 'stylesheets/bootstrap/mixins'));
// Import css from bootstrap
app.import(path_join(emberBsPath, 'css/bs-growl-notifications.min.css'));
if ((jsFiles !== []) && (jsFiles !== false) ) {
// Import javascript files from bootstrap-for-ember
app.import(path_join(javascriptsPath, 'bs-core.max.js')); // Import bs-core first
jsFiles.forEach(function(file) {
var fileName = file.split('.')[0];
app.import(path_join(javascriptsPath, fileName + '.max.js'));
});
}
// Import js from bootstrap
if(ibs_opts === true) {
app.import(path_join(bootstrapPath, 'javascripts/bootstrap.js'));
} else if (ibs_opts instanceof Array){
ibs_opts.forEach(function(fileName) {
app.import(path_join(bootstrapPath, 'javascripts/bootstrap', fileName + '.js'));
});
}
// Import glyphicons
app.import(path_join(bootstrapPath, 'fonts/bootstrap/glyphicons-halflings-regular.eot'), { destDir: '/fonts/bootstrap' });
app.import(path_join(bootstrapPath, 'fonts/bootstrap/glyphicons-halflings-regular.svg'), { destDir: '/fonts/bootstrap' });
app.import(path_join(bootstrapPath, 'fonts/bootstrap/glyphicons-halflings-regular.ttf'), { destDir: '/fonts/bootstrap' });
app.import(path_join(bootstrapPath, 'fonts/bootstrap/glyphicons-halflings-regular.woff'), { destDir: '/fonts/bootstrap' });
}
};