-
Notifications
You must be signed in to change notification settings - Fork 0
/
cordova.js
84 lines (69 loc) · 2.02 KB
/
cordova.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Copyright (c) 2015-2017 PointSource, LLC.
* MIT Licensed
*/
'use strict';
var fs = require('fs');
var path = require('path');
var procSpawn = require('./bundled/node_modules/superspawn').spawn;
module.exports.installCordova = function(data, {chalk, logger, files}) {
var cordovaDir = path.join('cordova');
logger.log(chalk.yellow('Adding Cordova environments: ' + data.name + ' : ' + data.cordovaPackageName));
var theProcess = procSpawn('cordova', ['create', 'cordova', data.cordovaPackageName, data.name], {
printCommand: true,
stdio: 'inherit'
});
return theProcess.then(
function() {
fs.writeFileSync('cordova/www/.gitkeep', '');
if (data.isCordovaIOS) {
logger.log(chalk.yellow('Adding IOS Cordova environment'));
return procSpawn('cordova', ['platform', 'add', 'ios', '--save'], {
cwd: cordovaDir,
printCommand: true,
stdio: 'inherit'
});
}
},
function(err) {
logger.fatal(chalk.red.bold('Cordova create error: ' + err));
}
).then(
function() {
if (data.isCordovaIOS) {
fs.writeFileSync('cordova/platforms/ios/www/.gitkeep', '');
}
if (data.isCordovaAndroid) {
logger.log(chalk.yellow('Adding Android Cordova environment'));
return procSpawn('cordova', ['platform', 'add', 'android', '--save'], {
cwd: cordovaDir,
printCommand: true,
stdio: 'inherit'
});
}
},
function(err) {
logger.fatal(chalk.red.bold('Cordova add ios error: ' + err));
}
).then(
function() {
if (data.isCordovaAndroid) {
fs.writeFileSync('cordova/platforms/android/assets/.gitkeep', '');
}
logger.log(chalk.yellow('Adding Cordova splashscreen plugin'));
return procSpawn('cordova', ['plugin', 'add', 'cordova-plugin-splashscreen', '--save'], {
cwd: cordovaDir,
printCommand: true,
stdio: 'inherit'
});
},
function(err) {
logger.fatal(chalk.red.bold('Cordova add android error: ' + err));
}
).then(
null,
function(err) {
logger.fatal(chalk.red.bold('Cordova add splashscreen plugin error: ' + err));
}
);
};