@@ -26,7 +26,7 @@ export class LinuxTargetHelper {
26
26
return this . iconsFromDir ( path . join ( this . packager . buildResourcesDir , "icons" ) )
27
27
}
28
28
else {
29
- return this . createFromIcns ( await this . packager . getTempFile ( "electron-builder-linux" ) . then ( it => ensureDir ( it ) . thenReturn ( it ) ) )
29
+ return this . createFromIcns ( await this . packager . getTempFile ( "electron-builder-linux.iconset " ) . then ( it => ensureDir ( it ) . thenReturn ( it ) ) )
30
30
}
31
31
}
32
32
@@ -103,39 +103,71 @@ export class LinuxTargetHelper {
103
103
return this . iconsFromDir ( path . join ( __dirname , ".." , ".." , "templates" , "linux" , "electron-icons" ) )
104
104
}
105
105
106
- const output = await exec ( "icns2png" , [ "-x" , "-o" , tempDir , iconPath ] )
107
- debug ( output )
106
+ if ( process . platform === "darwin" ) {
107
+ await exec ( "iconutil" , [ "--convert" , "iconset" , "--output" , tempDir , iconPath ] )
108
+ const iconFiles = await readdir ( tempDir )
109
+ const imagePath = iconFiles . includes ( "icon_512x512.png" ) ? path . join ( tempDir , "icon_512x512.png" ) : path . join ( tempDir , "icon_256x256.png" )
110
+ this . maxIconPath = imagePath
108
111
109
- //noinspection UnnecessaryLocalVariableJS
110
- const imagePath = path . join ( tempDir , "icon_256x256x32. png" )
112
+ function resize ( size : number ) : BluebirdPromise < any > {
113
+ const filename = `icon_ ${ size } x ${ size } . png`
111
114
112
- this . maxIconPath = imagePath
115
+ if ( iconFiles . includes ( filename ) ) {
116
+ return BluebirdPromise . resolve ( )
117
+ }
113
118
114
- function resize ( size : number ) : BluebirdPromise < any > {
115
- const sizeArg = `${ size } x${ size } `
116
- return exec ( "gm" , [ "convert" , "-size" , sizeArg , imagePath , "-resize" , sizeArg , path . join ( tempDir , `icon_${ size } x${ size } x32.png` ) ] )
117
- }
119
+ const sizeArg = `${ size } x${ size } `
120
+ return exec ( "gm" , [ "convert" , "-size" , sizeArg , imagePath , "-resize" , sizeArg , path . join ( tempDir , filename ) ] )
121
+ }
118
122
119
- const promises : Array < Promise < any > > = [ resize ( 24 ) , resize ( 96 ) ]
120
- if ( ! output . includes ( "is32" ) ) {
123
+ const promises : Array < Promise < any > > = [ resize ( 24 ) , resize ( 96 ) ]
121
124
promises . push ( resize ( 16 ) )
122
- }
123
- if ( ! output . includes ( "ih32" ) ) {
124
125
promises . push ( resize ( 48 ) )
125
- }
126
- if ( ! output . toString ( ) . includes ( "icp6" ) ) {
127
126
promises . push ( resize ( 64 ) )
128
- }
129
- if ( ! output . includes ( "it32" ) ) {
130
127
promises . push ( resize ( 128 ) )
128
+ await BluebirdPromise . all ( promises )
129
+
130
+ return this . createMappings ( tempDir )
131
131
}
132
+ else {
133
+ const output = await exec ( "icns2png" , [ "-x" , "-o" , tempDir , iconPath ] )
134
+ debug ( output )
135
+
136
+ //noinspection UnnecessaryLocalVariableJS
137
+ const imagePath = path . join ( tempDir , "icon_256x256x32.png" )
138
+
139
+ this . maxIconPath = imagePath
132
140
133
- await BluebirdPromise . all ( promises )
141
+ function resize ( size : number ) : BluebirdPromise < any > {
142
+ const sizeArg = `${ size } x${ size } `
143
+ return exec ( "gm" , [ "convert" , "-size" , sizeArg , imagePath , "-resize" , sizeArg , path . join ( tempDir , `icon_${ size } x${ size } x32.png` ) ] )
144
+ }
145
+
146
+ const promises : Array < Promise < any > > = [ resize ( 24 ) , resize ( 96 ) ]
147
+ if ( ! output . includes ( "is32" ) ) {
148
+ promises . push ( resize ( 16 ) )
149
+ }
150
+ if ( ! output . includes ( "ih32" ) ) {
151
+ promises . push ( resize ( 48 ) )
152
+ }
153
+ if ( ! output . toString ( ) . includes ( "icp6" ) ) {
154
+ promises . push ( resize ( 64 ) )
155
+ }
156
+ if ( ! output . includes ( "it32" ) ) {
157
+ promises . push ( resize ( 128 ) )
158
+ }
159
+
160
+ await BluebirdPromise . all ( promises )
161
+
162
+ return this . createMappings ( tempDir )
163
+ }
164
+ }
134
165
166
+ private createMappings ( tempDir : string ) {
135
167
const appName = this . packager . appInfo . name
136
168
137
169
function createMapping ( size : string ) {
138
- return [ `${ tempDir } /icon_${ size } x${ size } x32.png` , `${ size } x${ size } /apps/${ appName } .png` ]
170
+ return [ process . platform === "darwin" ? ` ${ tempDir } /icon_ ${ size } x ${ size } .png` : `${ tempDir } /icon_${ size } x${ size } x32.png` , `${ size } x${ size } /apps/${ appName } .png` ]
139
171
}
140
172
141
173
return [
0 commit comments