Skip to content

Commit c778e2b

Browse files
committed
fix: Linux build fails at icon conversion #239
Closes #239
1 parent 8d16e7c commit c778e2b

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"ava-tf": "^0.12.4-beta.6",
7676
"babel-plugin-array-includes": "^2.0.3",
7777
"babel-plugin-transform-es2015-parameters": "^6.7.0",
78-
"electron-download": "^2.0.0",
78+
"electron-download": "^2.1.0",
7979
"eslint": "^2.4.0",
8080
"eslint-plugin-ava": "sindresorhus/eslint-plugin-ava",
8181
"ghooks": "^1.0.3",

src/linuxPackager.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Platform } from "./metadata"
55
import { dir as _tpmDir, TmpOptions } from "tmp"
66
import { exec, log } from "./util"
77
import { State as Gm } from "gm"
8-
import { outputFile, readFile } from "fs-extra-p"
8+
import { outputFile, readFile, stat } from "fs-extra-p"
99
const template = require("lodash.template")
1010

1111
//noinspection JSUnusedLocalSymbols
@@ -69,14 +69,31 @@ Icon=${this.metadata.name}
6969

7070
private async computeDesktopIconPath(tempDir: string): Promise<Array<string>> {
7171
const outputs = await exec("icns2png", ["-x", "-o", tempDir, path.join(this.buildResourcesDir, "icon.icns")])
72+
log(outputs[0].toString())
7273
if (!outputs[0].toString().includes("ih32")) {
73-
log("48x48 is not found in the icns, 128x128 will be resized")
74+
log("48x48 is not found in the icns, 128x128 or 256x256 will be resized")
75+
76+
const gm = require("gm")
77+
7478
// icns doesn't contain required 48x48, use gm to resize
75-
await new BluebirdPromise((resolve, reject) => {
76-
(<Gm>require("gm")(path.join(tempDir, "icon_128x128x32.png")))
77-
.resize(48, 48)
78-
.write(path.join(tempDir, "icon_48x48x32.png"), error => error == null ? resolve() : reject(error))
79-
})
79+
function resize(imagePath: string, size: number): BluebirdPromise<any> {
80+
return new BluebirdPromise((resolve, reject) => {
81+
(<Gm>gm(imagePath))
82+
.resize(size, size)
83+
.write(path.join(tempDir, `icon_${size}x${size}x32.png`), error => error == null ? resolve() : reject(error))
84+
})
85+
}
86+
87+
let imagePath = path.join(tempDir, "icon_128x128x32.png")
88+
try {
89+
await stat(imagePath)
90+
}
91+
catch (e) {
92+
imagePath = path.join(tempDir, "icon_256x256x32.png")
93+
// 128 should be in any case
94+
await resize(imagePath, 128)
95+
}
96+
await resize(imagePath, 48)
8097
}
8198

8299
const name = this.metadata.name

0 commit comments

Comments
 (0)