-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.js
50 lines (43 loc) · 1.35 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
43
44
45
46
47
48
49
50
const {exec} = require('child_process');
const action = process.argv[2];
let platform = process.argv[3];
// Validate action
if (['build', 'debug', 'run'].indexOf(action) === -1) {
console.error('Invalid action')
process.exit(1);
}
// Validation platform
if ([undefined, 'android', 'ios'].indexOf(platform) === -1) {
console.error('Invalid platform')
process.exit(1);
}
switch (action) {
case 'build':
console.info('Building NativeScript application...')
break;
case 'debug':
console.info('Debugging NativeScript application...')
break;
case 'run':
console.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);
tnsAndroidProcess.on('exit', function (code) {
if (code !== 0) process.exit(code)
});
tnsiOSProcess.stdout.pipe(process.stdout);
tnsiOSProcess.on('exit', function (code) {
if (code !== 0) process.exit(code)
});
}
else {
let tnsProcess = exec(`tns --path dist ${action} ${platform || ''}`);
tnsProcess.stdout.pipe(process.stdout);
tnsProcess.on('exit', function (code) {
if (code !== 0) process.exit(code)
});
}