-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.js
42 lines (35 loc) · 1.06 KB
/
launch.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
const {exec} = require('child_process');
const winston = require('winston-color');
const action = process.argv[2];
let platform = process.argv[3];
// Validate action
if (['build', 'debug', 'run'].indexOf(action) === -1) {
winston.error('Invalid action');
process.exit(1);
}
// Validation platform
if ([undefined, 'android', 'ios'].indexOf(platform) === -1) {
winston.error('Invalid platform');
process.exit(1);
}
switch (action) {
case 'build':
winston.info('Building NativeScript application...');
break;
case 'debug':
winston.info('Debugging NativeScript application...');
break;
case 'run':
winston.info('Running NativeScript application...');
break;
}
if (action !== 'run' && !platform) {
let tnsAndroidProcess = exec(`tns --path dist ${action} android`);
let tnsiOSProcess = exec(`tns --path dist ${action} ios`);
tnsAndroidProcess.stdout.pipe(process.stdout);
tnsiOSProcess.stdout.pipe(process.stdout);
}
else {
let tnsProcess = exec(`tns --path dist ${action} ${platform || ''}`);
tnsProcess.stdout.pipe(process.stdout);
}