forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbower.js
More file actions
59 lines (48 loc) · 1.48 KB
/
bower.js
File metadata and controls
59 lines (48 loc) · 1.48 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
require('shelljs/global')
var fs = require('fs'),
path = require('path'),
colors = require('colors');
exports.IonicBower = {
setIonicVersion: function(newVersion) {
var bowerData = this.getData();
if (!bowerData.devDependencies) bowerData.devDependencies = {};
bowerData.devDependencies.ionic = 'driftyco/ionic-bower#' + newVersion;
this.saveData(bowerData);
},
setAppName: function(newAppName) {
var bowerData = this.getData();
bowerData.name = newAppName;
this.saveData(bowerData);
},
getData: function() {
var bowerFilePath = path.resolve('bower.json');
try {
if (fs.existsSync(bowerFilePath)) {
return require(bowerFilePath);
}
} catch (e) {}
return {
"name": "HelloIonic",
"private": "true"
};
},
saveData: function(bowerData) {
try {
var bowerFilePath = path.resolve('bower.json');
fs.writeFileSync(bowerFilePath, JSON.stringify(bowerData, null, 2));
} catch (e) {
console.log(('Error saving ' + bowerFilePath + ': ' + e).error.bold);
}
},
checkForBower: function checkForBower() {
var installed = false;
try {
var result = exec('bower -v', {silent: true});
if (result.output.indexOf('command not found') == -1 && result.output.indexOf('not recognized') == -1) {
installed = true;
}
} catch (ex) { }
return installed;
},
installMessage: 'You must have bower installed to continue. \nType `npm install -g bower`'
};