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
44 lines (36 loc) · 1.04 KB
/
bower.js
File metadata and controls
44 lines (36 loc) · 1.04 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
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 );
}
}
};