forked from Panman82/ember-bootstrap-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (44 loc) · 1.78 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
66
67
68
/* jshint node: true */
'use strict';
// module requirements
var fs = require('fs');
module.exports = {
name: 'ember-bootstrap-switch',
included: function(app) {
// Addon options from the apps Brocfile.js
var options = app.options[this.name] || {};
// Version of bootstrap-switch to use
options.boostrapVersion = options.bootstrapVersion || 3;
// Path to bootstrap-switch in bower
var bootstrapSwitchPath = app.bowerDirectory + '/bootstrap-switch/dist';
var bootstrapSwitchCssPath = bootstrapSwitchPath + '/css/bootstrap' + options.boostrapVersion;
// Make sure bootstrap-switch is available
if (!fs.existsSync(bootstrapSwitchPath)) {
throw new Error(
this.name + ': bootstrap-switch is not available from bower (' + bootstrapSwitchPath + '), ' +
'install into your project by `bower install bootstrap-switch --save`'
);
}
// Make sure bootstrap-switch css is available
if (!options.excludeCSS && !fs.existsSync(bootstrapSwitchCssPath)) {
throw new Error(
this.name + ': bootstrap-switch css version is not available from bower (' + bootstrapSwitchCssPath + '), ' +
'if you specify the `bootstrapVersion` be sure it is a valid option (currently 2 or 3)'
);
}
// Import bootstrap-switch js
if (!options.excludeJS) {
app.import({
development: bootstrapSwitchPath + '/js/bootstrap-switch.js',
production: bootstrapSwitchPath + '/js/bootstrap-switch.min.js'
});
}
// Import bootstrap-switch css
if (!options.excludeCSS) {
app.import({
development: bootstrapSwitchCssPath + '/bootstrap-switch.css',
production: bootstrapSwitchCssPath + '/bootstrap-switch.min.css'
});
}
} // :included
}; // module.exports