From 2154934eddbd6834c06fcd099cfeb5770de33819 Mon Sep 17 00:00:00 2001 From: develar Date: Fri, 23 Feb 2018 19:21:09 +0100 Subject: [PATCH] fix(linux): icon.icns is not used for Linux icon Close #2617 --- package.json | 2 +- packages/builder-util/package.json | 2 +- packages/electron-builder-lib/package.json | 2 +- .../src/targets/LinuxTargetHelper.ts | 2 ++ .../__snapshots__/linuxPackagerTest.js.snap | 32 +++++++++++++++++ test/src/linux/linuxPackagerTest.ts | 34 +++++++++++++++++-- yarn.lock | 30 ++++++++-------- 7 files changed, 83 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index e2023dcbb6b..bc840434d36 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "////": "All typings are added into root `package.json` to avoid duplication errors in the IDE compiler (several `node.d.ts` files).", "dependencies": { "7zip-bin": "~3.1.0", - "app-builder-bin": "1.4.0", + "app-builder-bin": "1.4.1", "archiver": "^2.1.1", "async-exit-hook": "^2.0.1", "aws-sdk": "^2.201.0", diff --git a/packages/builder-util/package.json b/packages/builder-util/package.json index 07cef46c3f0..18c842d4c93 100644 --- a/packages/builder-util/package.json +++ b/packages/builder-util/package.json @@ -11,7 +11,7 @@ "out" ], "dependencies": { - "app-builder-bin": "1.4.0", + "app-builder-bin": "1.4.1", "temp-file": "^3.1.1", "fs-extra-p": "^4.5.2", "is-ci": "^1.1.0", diff --git a/packages/electron-builder-lib/package.json b/packages/electron-builder-lib/package.json index 5b299338f05..3e3f0b7ad30 100644 --- a/packages/electron-builder-lib/package.json +++ b/packages/electron-builder-lib/package.json @@ -42,7 +42,7 @@ "homepage": "https://github.com/electron-userland/electron-builder", "dependencies": { "7zip-bin": "~3.1.0", - "app-builder-bin": "1.4.0", + "app-builder-bin": "1.4.1", "async-exit-hook": "^2.0.1", "bluebird-lst": "^1.0.5", "chromium-pickle-js": "^0.2.0", diff --git a/packages/electron-builder-lib/src/targets/LinuxTargetHelper.ts b/packages/electron-builder-lib/src/targets/LinuxTargetHelper.ts index 9538af99eb8..66986da4784 100644 --- a/packages/electron-builder-lib/src/targets/LinuxTargetHelper.ts +++ b/packages/electron-builder-lib/src/targets/LinuxTargetHelper.ts @@ -36,6 +36,8 @@ export class LinuxTargetHelper { sources.push(icnsPath) } + sources.push("icon.icns") + sources.push(path.join(getTemplatePath("linux"), "electron-icons")) const result = await packager.resolveIcon(sources, "set") diff --git a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap index 20431dc844f..1b2afabfeed 100644 --- a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap +++ b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap @@ -176,6 +176,38 @@ Object { } `; +exports[`icons from ICNS if nothing specified 1`] = ` +Object { + "linux": Array [ + Object { + "arch": "x64", + "file": "TestApp-1.1.0-x86_64.AppImage", + "updateInfo": Object { + "blockMapSize": "@blockMapSize", + "sha512": "@sha512", + "size": "@size", + }, + }, + ], +} +`; + +exports[`icons from dir and one icon with suffix 1`] = ` +Object { + "linux": Array [ + Object { + "arch": "x64", + "file": "TestApp-1.1.0-x86_64.AppImage", + "updateInfo": Object { + "blockMapSize": "@blockMapSize", + "sha512": "@sha512", + "size": "@size", + }, + }, + ], +} +`; + exports[`no-author-email 1`] = ` "Please specify author 'email' in the application package.json diff --git a/test/src/linux/linuxPackagerTest.ts b/test/src/linux/linuxPackagerTest.ts index 726829d5b55..d711fc22d18 100644 --- a/test/src/linux/linuxPackagerTest.ts +++ b/test/src/linux/linuxPackagerTest.ts @@ -1,5 +1,5 @@ import { Arch, build, Platform } from "electron-builder" -import { move, remove, rename } from "fs-extra-p" +import { copyFile, move, remove, rename } from "fs-extra-p" import * as path from "path" import { assertThat } from "../helpers/fileAssert" import { app, appThrows, modifyPackageJson } from "../helpers/packTester" @@ -83,8 +83,36 @@ test.ifNotWindows("icons from ICNS (mac)", app({ }, }, }, { - projectDirCreated: it => move(path.join(it, "build", "icon.icns"), path.join(it, "resources", "time.icns")) - .then(() => remove(path.join(it, "build"))), + projectDirCreated: async projectDir => { + await move(path.join(projectDir, "build", "icon.icns"), path.join(projectDir, "resources", "time.icns")) + await remove(path.join(projectDir, "build")) + }, + packed: async context => { + const projectDir = context.getResources(Platform.LINUX) + await assertThat(projectDir).isDirectory() + }, +})) + +test.ifNotWindows("icons from ICNS if nothing specified", app({ + targets: appImageTarget, + config: { + publish: null, + }, +}, { + projectDirCreated: async projectDir => { + await remove(path.join(projectDir, "build", "icons")) + }, +})) + +test.ifNotWindows("icons from dir and one icon with suffix", app({ + targets: appImageTarget, + config: { + publish: null, + }, +}, { + projectDirCreated: async projectDir => { + await copyFile(path.join(projectDir, "build", "icons", "16x16.png"), path.join(projectDir, "build", "icons", "16x16-dev.png")) + }, packed: async context => { const projectDir = context.getResources(Platform.LINUX) await assertThat(projectDir).isDirectory() diff --git a/yarn.lock b/yarn.lock index fd7b878fa96..50f921ab9fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -275,25 +275,25 @@ anymatch@^1.3.0: micromatch "^2.1.5" normalize-path "^2.0.0" -app-builder-bin-linux@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/app-builder-bin-linux/-/app-builder-bin-linux-1.4.0.tgz#8a5f1af5e4dd4c57efa00c2ba48864d872bad985" +app-builder-bin-linux@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/app-builder-bin-linux/-/app-builder-bin-linux-1.4.1.tgz#00eca4fbd3e9bdb04073b94b06c5a2c4a659f3d1" -app-builder-bin-mac@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/app-builder-bin-mac/-/app-builder-bin-mac-1.4.0.tgz#415c12362a055aac9859feb70a66f5384f654c09" +app-builder-bin-mac@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/app-builder-bin-mac/-/app-builder-bin-mac-1.4.1.tgz#7385b1ed97e58ac4d8e3dc3b5dc6d76b67d97d8d" -app-builder-bin-win@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/app-builder-bin-win/-/app-builder-bin-win-1.4.0.tgz#2e0df892c8cf686c47a54cfeeb60d6fe77837e10" +app-builder-bin-win@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/app-builder-bin-win/-/app-builder-bin-win-1.4.1.tgz#30806d14b13bdb7fce4021a7d4f5a9c9ecc9708e" -app-builder-bin@1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-1.4.0.tgz#4e0903bd65aad1e715f8b22b40bbb2cd611bd39f" +app-builder-bin@1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-1.4.1.tgz#3ae86df2d3eb624ad93d097abe986fe07c2f5aca" optionalDependencies: - app-builder-bin-linux "1.4.0" - app-builder-bin-mac "1.4.0" - app-builder-bin-win "1.4.0" + app-builder-bin-linux "1.4.1" + app-builder-bin-mac "1.4.1" + app-builder-bin-win "1.4.1" append-transform@^0.4.0: version "0.4.0"