@@ -3,7 +3,7 @@ const chalk = require('chalk')
3
3
const child_process = require ( 'child_process' )
4
4
const fs = require ( 'fs' )
5
5
const inquirer = require ( 'inquirer' )
6
-
6
+ const copy = require ( 'copy' )
7
7
const utils = require ( '../utils' )
8
8
const startJSServer = require ( './server' )
9
9
const { Config, androidConfigResolver} = require ( '../utils/config' )
@@ -12,10 +12,15 @@ const {Config,androidConfigResolver} = require('../utils/config')
12
12
* @param {Object } options
13
13
*/
14
14
function runAndroid ( options ) {
15
-
15
+ console . log ( ` => ${ chalk . blue . bold ( 'npm install&build' ) } ` )
16
16
utils . buildJS ( )
17
17
. then ( ( ) => {
18
- return utils . exec ( 'rsync -r -R -q ./dist/* android/playground/app/src/main/assets/' )
18
+ return new Promise ( ( resolve , reject ) => {
19
+ copy ( './dist/*' , 'android/playground/app/src/main/assets/' , function ( err ) {
20
+ if ( err ) return reject ( err ) ;
21
+ else resolve ( ) ;
22
+ } )
23
+ } ) ;
19
24
} )
20
25
. then ( ( ) => {
21
26
startJSServer ( )
@@ -32,7 +37,7 @@ function runAndroid(options) {
32
37
. then ( runApp )
33
38
. catch ( ( err ) => {
34
39
if ( err ) {
35
- console . log ( 111 , err )
40
+ console . log ( chalk . red ( 'Error:' , err ) ) ;
36
41
}
37
42
} )
38
43
}
@@ -86,7 +91,7 @@ function resolveConfig({options,rootPath}){
86
91
let androidConfig = new Config ( androidConfigResolver , path . join ( rootPath , 'android.config.json' ) ) ;
87
92
return androidConfig . getConfig ( ) . then ( ( config ) => {
88
93
androidConfigResolver . resolve ( config ) ;
89
- return { } ;
94
+ return { options , rootPath } ;
90
95
} )
91
96
}
92
97
/**
@@ -174,8 +179,11 @@ function reverseDevice({device, options}) {
174
179
function buildApp ( { device, options} ) {
175
180
return new Promise ( ( resolve , reject ) => {
176
181
console . log ( ` => ${ chalk . blue . bold ( 'Building app ...' ) } ` )
182
+
183
+ let clean = options . clean ?' clean' :'' ;
184
+ console . log ( options , clean ) ;
177
185
try {
178
- child_process . execSync ( `. /gradlew clean assemble`, { encoding : 'utf8' , stdio : [ 0 , 1 , 2 ] } )
186
+ child_process . execSync ( process . platform === 'win32' ? `call gradlew.bat ${ clean } assemble` : `. /gradlew${ clean } assemble`, { encoding : 'utf8' , stdio : [ 0 , 1 , 2 ] } )
179
187
} catch ( e ) {
180
188
reject ( )
181
189
}
0 commit comments