@@ -99,7 +99,7 @@ function PlatformBase (id, name, packageName, baseDir) {
99
99
100
100
/**
101
101
* Returns an array of icons files as defined in the manifest. The method assumes that all icons
102
- * are defined as properties of an 'icons' member, for example:
102
+ * are are square and defined as properties of an 'icons' member, for example:
103
103
* "icons": {
104
104
* "30": "/images/smalllogo.png",
105
105
* "50": "/images/storelogo.png",
@@ -112,8 +112,25 @@ function PlatformBase (id, name, packageName, baseDir) {
112
112
} ;
113
113
114
114
/**
115
- * Adds an icon file to the manifest. The method assumes that all icons are
116
- * defined as properties of an 'icons' member, for example:
115
+ * Receives the size (e.g. '50x50') of an icon and returns the corresponding icon element
116
+ * from the manifest or undefined if not found. The method assumes that all icons
117
+ * are square and defined as properties of an 'icons' member, for example:
118
+ * "icons": {
119
+ * "30": "/images/smalllogo.png",
120
+ * "50": "/images/storelogo.png",
121
+ * "150": "/images/logo.png"
122
+ * }
123
+ * Platforms should override this method if the manifest icons use a different format.
124
+ */
125
+ self . getManifestIcon = function ( manifest , size ) {
126
+ // assumes icons are square
127
+ var dimensions = size . toLowerCase ( ) . split ( 'x' ) ;
128
+ return manifest . icons && manifest . icons [ dimensions [ 0 ] ] ;
129
+ } ;
130
+
131
+ /**
132
+ * Adds an icon file with the specified size (e.g. '50x50') to the manifest. The method
133
+ * assumes that all icons are square and defined as properties of an 'icons' member, for example:
117
134
* "icons": {
118
135
* "30": "/images/smalllogo.png",
119
136
* "50": "/images/storelogo.png",
@@ -141,9 +158,6 @@ function PlatformBase (id, name, packageName, baseDir) {
141
158
var iconList = manifest . icons ;
142
159
return Q . resolve ( ) . then ( function ( ) {
143
160
if ( iconList ) {
144
- // var icons = Array.isArray(iconList) ?
145
- // iconList.map(function (icon) { return icon.src; }) :
146
- // Object.keys(iconList).map(function (size) { return manifest.icons[size]; });
147
161
var icons = self . getManifestIcons ( manifest ) ;
148
162
149
163
var downloadTasks = icons . map ( function ( icon ) {
@@ -166,7 +180,15 @@ function PlatformBase (id, name, packageName, baseDir) {
166
180
// copy default platform icons to replace any missing icons
167
181
. then ( function ( ) {
168
182
var defaultImagesDir = path . join ( self . baseDir , 'assets' , 'images' ) ;
169
- return fileTools . syncFiles ( defaultImagesDir , imagesDir ) . then ( function ( files ) {
183
+ return fileTools . syncFiles ( defaultImagesDir , imagesDir , {
184
+ // filter out default images that do not need to be moved over
185
+ filter : function ( file ) {
186
+ // determine the icon dimensions assuming a convention where
187
+ // the file name specifies the icon's size (e.g. '50x50.png')
188
+ var size = path . basename ( file , path . extname ( file ) ) ;
189
+ return ! self . getManifestIcon ( manifest , size ) ;
190
+ }
191
+ } ) . then ( function ( files ) {
170
192
files . forEach ( function ( file ) {
171
193
// make path relative to imagesDir
172
194
var filePath = path . relative ( imagesDir , file ) ;
@@ -181,7 +203,7 @@ function PlatformBase (id, name, packageName, baseDir) {
181
203
return Q . reject ( err ) ;
182
204
}
183
205
184
- self . warn ( 'No default icons were found to copy for the \'' + self . id + '\' platform.' ) ;
206
+ self . debug ( 'No default icons were found to copy for the \'' + self . id + '\' platform.' ) ;
185
207
} ) ;
186
208
} )
187
209
. nodeify ( callback ) ;
0 commit comments