@@ -236,33 +236,36 @@ export class ProjectDataService implements IProjectDataService {
236
236
private async getIOSAssetSubGroup ( dirPath : string ) : Promise < IAssetSubGroup > {
237
237
const pathToContentJson = path . join ( dirPath , AssetConstants . iOSResourcesFileName ) ;
238
238
const content = this . $fs . exists ( pathToContentJson ) && < IAssetSubGroup > this . $fs . readJson ( pathToContentJson ) || { images : [ ] } ;
239
+ const finalContent : IAssetSubGroup = { images : [ ] } ;
239
240
240
241
const imageDefinitions = this . getImageDefinitions ( ) . ios ;
241
242
242
243
_ . each ( content && content . images , image => {
244
+ let foundMatchingDefinition = false ;
243
245
// In some cases the image may not be available, it will just be described.
244
246
// When this happens, the filename will be empty.
245
247
// So we'll keep the path empty as well.
246
248
if ( image . filename ) {
247
249
image . path = path . join ( dirPath , image . filename ) ;
248
250
}
249
251
252
+ if ( image . size ) {
253
+ // size is basically <width>x<height>
254
+ const [ width , height ] = image . size . toString ( ) . split ( AssetConstants . sizeDelimiter ) ;
255
+ if ( width && height ) {
256
+ image . width = + width ;
257
+ image . height = + height ;
258
+ }
259
+ }
260
+
250
261
// Find the image size based on the hardcoded values in the image-definitions.json
251
262
_ . each ( imageDefinitions , ( assetSubGroup : IAssetItem [ ] ) => {
252
263
const assetItem = _ . find ( assetSubGroup , assetElement =>
253
264
assetElement . filename === image . filename && path . basename ( assetElement . directory ) === path . basename ( dirPath )
254
265
) ;
255
266
256
- if ( image . size ) {
257
- // size is basically <width>x<height>
258
- const [ width , height ] = image . size . toString ( ) . split ( AssetConstants . sizeDelimiter ) ;
259
- if ( width && height ) {
260
- image . width = + width ;
261
- image . height = + height ;
262
- }
263
- }
264
-
265
267
if ( assetItem ) {
268
+ foundMatchingDefinition = true ;
266
269
if ( ! image . width || ! image . height ) {
267
270
image . width = assetItem . width ;
268
271
image . height = assetItem . height ;
@@ -273,13 +276,18 @@ export class ProjectDataService implements IProjectDataService {
273
276
image . overlayImageScale = image . overlayImageScale || assetItem . overlayImageScale ;
274
277
image . scale = image . scale || assetItem . scale ;
275
278
image . rgba = assetItem . rgba ;
279
+ finalContent . images . push ( image ) ;
276
280
// break each
277
281
return false ;
278
282
}
279
283
} ) ;
284
+
285
+ if ( ! foundMatchingDefinition && image . filename ) {
286
+ this . $logger . warn ( `Didn't find a matching image definition for file ${ path . join ( path . basename ( dirPath ) , image . filename ) } . This file will be skipped from reources generation.` ) ;
287
+ }
280
288
} ) ;
281
289
282
- return content ;
290
+ return finalContent ;
283
291
}
284
292
285
293
private getAndroidAssetSubGroup ( assetItems : IAssetItem [ ] , realPaths : string [ ] ) : IAssetSubGroup {
0 commit comments