@@ -169,7 +169,7 @@ const ANDROID_SPLASHES: readonly ProcessItem[] = [
169
169
} ,
170
170
] ;
171
171
172
- async function copyImages ( sourcePath : string , targetPath : string , images : readonly ProcessItem [ ] ) {
172
+ async function copyImages ( sourcePath : string , targetPath : string , images : readonly ProcessItem [ ] ) : Promise < number > {
173
173
await Promise . all ( images . map ( async item => {
174
174
const source = path . join ( sourcePath , item . source ) ;
175
175
const target = path . join ( targetPath , item . target ) ;
@@ -178,20 +178,33 @@ async function copyImages(sourcePath: string, targetPath: string, images: readon
178
178
179
179
await copy ( source , target ) ;
180
180
} ) ) ;
181
+
182
+ return images . length ;
181
183
}
182
184
183
- export async function copyToNativeProject ( platform : Platform , nativeProject : NativeProjectConfig , logstream : NodeJS . WritableStream | null , errstream : NodeJS . WritableStream | null ) {
185
+ export async function copyToNativeProject ( platform : Platform , nativeProject : NativeProjectConfig , shouldCopyIcons : boolean , shouldCopySplash : boolean , logstream : NodeJS . WritableStream | null , errstream : NodeJS . WritableStream | null ) {
186
+ let count = 0 ;
187
+
184
188
if ( platform === Platform . IOS ) {
185
189
const iosProjectDirectory = nativeProject . directory || 'ios' ;
186
- await copyImages ( SOURCE_IOS_ICON , path . join ( iosProjectDirectory , TARGET_IOS_ICON ) , IOS_ICONS ) ;
187
- await copyImages ( SOURCE_IOS_SPLASH , path . join ( iosProjectDirectory , TARGET_IOS_SPLASH ) , IOS_SPLASHES ) ;
188
- logstream ?. write ( util . format ( `Copied %s resource items to %s` , IOS_ICONS . length + IOS_SPLASHES . length , prettyPlatform ( platform ) ) + '\n' ) ;
190
+ if ( shouldCopyIcons ) {
191
+ count += await copyImages ( SOURCE_IOS_ICON , path . join ( iosProjectDirectory , TARGET_IOS_ICON ) , IOS_ICONS ) ;
192
+ }
193
+ if ( shouldCopySplash ) {
194
+ count += await copyImages ( SOURCE_IOS_SPLASH , path . join ( iosProjectDirectory , TARGET_IOS_SPLASH ) , IOS_SPLASHES ) ;
195
+ }
189
196
} else if ( platform === Platform . ANDROID ) {
190
197
const androidProjectDirectory = nativeProject . directory || 'android' ;
191
- await copyImages ( SOURCE_ANDROID_ICON , path . join ( androidProjectDirectory , TARGET_ANDROID_ICON ) , ANDROID_ICONS ) ;
192
- await copyImages ( SOURCE_ANDROID_SPLASH , path . join ( androidProjectDirectory , TARGET_ANDROID_SPLASH ) , ANDROID_SPLASHES ) ;
193
- logstream ?. write ( util . format ( `Copied %s resource items to %s` , ANDROID_ICONS . length + ANDROID_SPLASHES . length , prettyPlatform ( platform ) ) + '\n' ) ;
198
+ if ( shouldCopyIcons ) {
199
+ count += await copyImages ( SOURCE_ANDROID_ICON , path . join ( androidProjectDirectory , TARGET_ANDROID_ICON ) , ANDROID_ICONS ) ;
200
+ }
201
+ if ( shouldCopySplash ) {
202
+ count += await copyImages ( SOURCE_ANDROID_SPLASH , path . join ( androidProjectDirectory , TARGET_ANDROID_SPLASH ) , ANDROID_SPLASHES ) ;
203
+ }
194
204
} else {
195
205
errstream ?. write ( util . format ( 'WARN:\tCopying to native projects is not supported for %s' , prettyPlatform ( platform ) ) + '\n' ) ;
206
+ return ;
196
207
}
208
+
209
+ logstream ?. write ( util . format ( `Copied %s resource items to %s` , count , prettyPlatform ( platform ) ) + '\n' ) ;
197
210
}
0 commit comments