1
1
///<reference path="../.d.ts"/>
2
2
3
+ import Future = require( "fibers/future" ) ;
3
4
import path = require( "path" ) ;
4
5
import shell = require( "shelljs" ) ;
5
6
import util = require( "util" ) ;
@@ -86,9 +87,16 @@ class IOSProjectService implements IPlatformProjectService {
86
87
return ( ( ) => {
87
88
var appSourceDirectory = path . join ( this . $projectData . projectDir , constants . APP_FOLDER_NAME ) ;
88
89
var appDestinationDirectory = path . join ( platformData . projectRoot , this . $projectData . projectName ) ;
90
+ var resDirectory = path . join ( platformData . projectRoot , this . $projectData . projectName , "Resources" , "icons" ) ;
89
91
90
92
shell . cp ( "-r" , path . join ( appSourceDirectory , "*" ) , appDestinationDirectory ) ;
91
93
94
+ var appResourcesDirectoryPath = path . join ( appDestinationDirectory , constants . APP_RESOURCES_FOLDER_NAME ) ;
95
+ if ( this . $fs . exists ( appResourcesDirectoryPath ) . wait ( ) ) {
96
+ shell . cp ( "-r" , path . join ( appResourcesDirectoryPath , platformData . normalizedPlatformName , "*" ) , resDirectory ) ;
97
+ this . $fs . deleteDirectory ( appResourcesDirectoryPath ) . wait ( ) ;
98
+ }
99
+
92
100
return appDestinationDirectory ;
93
101
} ) . future < string > ( ) ( ) ;
94
102
}
@@ -120,8 +128,7 @@ class IOSProjectService implements IPlatformProjectService {
120
128
] ) ;
121
129
}
122
130
123
- var childProcess = this . $childProcess . spawn ( "xcodebuild" , args , { cwd : options , stdio : 'inherit' } ) ;
124
- this . $fs . futureFromEvent ( childProcess , "exit" ) . wait ( ) ;
131
+ this . spawn ( "xcodebuild" , args , "exit" , { cwd : options , stdio : 'inherit' } ) . wait ( ) ;
125
132
126
133
if ( options . device ) {
127
134
var buildOutputPath = path . join ( projectRoot , "build" , options . device ? "device" : "emulator" ) ;
@@ -134,12 +141,29 @@ class IOSProjectService implements IPlatformProjectService {
134
141
"-o" , path . join ( buildOutputPath , this . $projectData . projectName + ".ipa" )
135
142
] ;
136
143
137
- var childProcess = this . $childProcess . spawn ( "xcrun" , xcrunArgs , { cwd : options , stdio : 'inherit' } ) ;
138
- this . $fs . futureFromEvent ( childProcess , "exit" ) . wait ( ) ;
144
+ this . spawn ( "xcrun" , xcrunArgs , "exit" , { cwd : options , stdio : 'inherit' } ) . wait ( ) ;
139
145
}
140
146
} ) . future < void > ( ) ( ) ;
141
147
}
142
148
149
+ private spawn ( command : string , args : string [ ] , event : string , options ?: any ) : IFuture < void > { // event should be exit or close
150
+ var future = new Future < void > ( ) ;
151
+ var childProcess = this . $childProcess . spawn ( command , args , options ) ;
152
+ childProcess . once ( event , ( ) => {
153
+ var args = _ . toArray ( arguments ) ;
154
+ var statusCode = args [ 0 ] ;
155
+ var signal = args [ 1 ] ;
156
+
157
+ if ( statusCode !== 0 ) {
158
+ future . throw ( util . format ( "Command %s exited with code %s" , command , statusCode ) ) ;
159
+ } else {
160
+ future . return ( ) ;
161
+ }
162
+ } ) ;
163
+
164
+ return future ;
165
+ }
166
+
143
167
private replaceFileContent ( file : string ) : IFuture < void > {
144
168
return ( ( ) => {
145
169
var fileContent = this . $fs . readText ( file ) . wait ( ) ;
0 commit comments