Skip to content

Commit

Permalink
test: prepackaged asar electron-userland#1102
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Feb 3, 2017
1 parent 6c977c4 commit fc14e2e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/programmaticUsage.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict"

const builder = require("electron-builder")
const Platform = builder.Platform

// Promise is returned
builder.build({
platform: [builder.Platform.MAC],
"//": "platform, arch and other properties, see PackagerOptions in the node_modules/electron-builder/out/electron-builder.d.ts",
targets: Platform.MAC.createTarget(),
config: {
"//": "build options, see https://goo.gl/ZhRfla"
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"source-map-support": "^0.4.11",
"ts-babel": "^1.3.5",
"tslint": "^4.4.2",
"typescript": "^2.1.5",
"typescript": "^2.2.0",
"whitespace": "^2.1.0"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-http/src/httpExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export abstract class HttpExecutor<REQUEST_OPTS, REQUEST> {
try {
const contentType = response.headers["content-type"]
const isJson = contentType != null && (Array.isArray(contentType) ? contentType.find(it => it.includes("json")) != null : contentType.includes("json"))
if (response.statusCode >= 400) {
if (response.statusCode != null && response.statusCode >= 400) {
reject(new HttpError(response, isJson ? JSON.parse(data) : data))
}
else {
Expand Down
5 changes: 3 additions & 2 deletions packages/electron-builder/src/targets/LinuxTargetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export class LinuxTargetHelper {
debug(output)

//noinspection UnnecessaryLocalVariableJS
const imagePath = path.join(tempDir, "icon_256x256x32.png")
const has256 = output.includes("ic08")
const imagePath = path.join(tempDir, has256 ? "icon_256x256x32.png" : "icon_128x128x32.png")

this.maxIconPath = imagePath

Expand All @@ -176,7 +177,7 @@ export class LinuxTargetHelper {
if (!output.toString().includes("icp6")) {
promises.push(resize(64))
}
if (!output.includes("it32")) {
if (has256 && !output.includes("it32")) {
promises.push(resize(128))
}

Expand Down
25 changes: 20 additions & 5 deletions test/src/linux/linuxPackagerTest.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { modifyPackageJson, app, appThrows } from "../helpers/packTester"
import { remove, readFile } from "fs-extra-p"
import { remove, readFile, rename } from "fs-extra-p"
import * as path from "path"
import { Platform } from "electron-builder"
import { Platform, build } from "electron-builder"
import { assertThat } from "../helpers/fileAssert"

test.ifDevOrLinuxCi("AppImage", app({targets: Platform.LINUX.createTarget()}))

test.ifDevOrLinuxCi("AppImage - default icon, custom executable and custom desktop", app({
targets: Platform.LINUX.createTarget("appimage"),
effectiveOptionComputed: async (it) => {
const content = await readFile(it[1], "utf-8")
expect (content.includes("Foo=bar")).toBeTruthy()
expect (content.includes("Terminal=true")).toBeTruthy()
expect(content.includes("Foo=bar")).toBeTruthy()
expect(content.includes("Terminal=true")).toBeTruthy()
return false
},
config: {
Expand All @@ -27,7 +28,21 @@ test.ifDevOrLinuxCi("AppImage - default icon, custom executable and custom deskt
}))

test.ifNotWindows("icons from ICNS", app({targets: Platform.LINUX.createTarget()}, {
projectDirCreated: it => remove(path.join(it, "build", "icons"))
projectDirCreated: it => remove(path.join(it, "build", "icons")),
packed: async context => {
// test https://github.com/electron-userland/electron-builder/issues/1102
const projectDir = context.getResources(Platform.LINUX)

await rename(path.join(projectDir, "electron.asar"), path.join(projectDir, "someAsarFile.asar"))

await build({
targets: Platform.LINUX.createTarget(),
projectDir: projectDir,
})

await assertThat(path.join(projectDir, "dist")).isDirectory()
await assertThat(path.join(projectDir, "dist", "linux-unpacked", "resources", "someAsarFile.asar")).isFile()
},
}))

test.ifNotWindows("no-author-email", appThrows(/Please specify author 'email' in .+/, {targets: Platform.LINUX.createTarget("deb")}, {
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2775,9 +2775,9 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"

typescript@^2.1.5:
version "2.1.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.5.tgz#6fe9479e00e01855247cea216e7561bafcdbcd4a"
typescript@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.2.0.tgz#626f2fc70087d2480f21ebb12c1888288c8614e3"

uc.micro@^1.0.1, uc.micro@^1.0.3:
version "1.0.3"
Expand Down

0 comments on commit fc14e2e

Please sign in to comment.