Skip to content

Commit

Permalink
test: wrong executable in .desktop electron-userland#1291
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Feb 23, 2017
1 parent 3fa6259 commit d1c26e9
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 219 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ajv": "^5.0.2-beta",
"ajv-keywords": "^2.0.1-beta.0",
"archiver": "^1.3.0",
"asar": "~0.13.0",
"asar-electron-builder": "~0.14.2",
"aws-sdk": "^2.17.0",
"bluebird-lst": "^1.0.1",
"chalk": "^1.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"ajv": "^5.0.2-beta",
"ajv-keywords": "^2.0.1-beta.0",
"7zip-bin": "^2.0.4",
"asar": "~0.13.0",
"asar-electron-builder": "~0.14.2",
"bluebird-lst": "^1.0.1",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsarFileInfo, listPackage, statFile } from "asar"
import { AsarFileInfo, listPackage, statFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst"
import { debug } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
Expand All @@ -10,7 +10,7 @@ import { AsarOptions } from "./metadata"

const isBinaryFile: any = BluebirdPromise.promisify(require("isbinaryfile"))
const pickle = require ("chromium-pickle-js")
const Filesystem = require("asar/lib/filesystem")
const Filesystem = require("asar-electron-builder/lib/filesystem")
const UINT64 = require("cuint").UINT64

const NODE_MODULES_PATTERN = `${path.sep}node_modules${path.sep}`
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractFile } from "asar"
import { extractFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst"
import { Arch, Platform, Target } from "electron-builder-core"
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
Expand Down
9 changes: 6 additions & 3 deletions packages/electron-builder/src/targets/fpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ export default class FpmTarget extends Target {
private readonly options = Object.assign({}, this.packager.platformSpecificBuildOptions, (<any>this.packager.config)[this.name])

private readonly scriptFiles: Promise<Array<string>>
private readonly desktopEntry: Promise<string>

constructor(name: string, private readonly packager: LinuxPackager, private readonly helper: LinuxTargetHelper, readonly outDir: string) {
super(name, false)

this.scriptFiles = this.createScripts()
this.desktopEntry = helper.computeDesktopEntry(this.options)
}

private async createScripts(): Promise<Array<string>> {
Expand Down Expand Up @@ -164,7 +162,12 @@ export default class FpmTarget extends Target {
args.push(mapping.join("=/usr/share/icons/hicolor/"))
}

args.push(`${await this.desktopEntry}=/usr/share/applications/${this.packager.executableName}.desktop`)
const desktopFilePath = await this.helper.computeDesktopEntry(this.options)
args.push(`${desktopFilePath}=/usr/share/applications/${this.packager.executableName}.desktop`)

if (this.packager.packagerOptions.effectiveOptionComputed != null && await this.packager.packagerOptions.effectiveOptionComputed([args, desktopFilePath])) {
return
}

await exec(await fpmPath, args)

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/util/readPackageJson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ajv from "ajv"
import { extractFile } from "asar"
import { extractFile } from "asar-electron-builder"
import { log, warn } from "electron-builder-util/out/log"
import { readFile, readJson } from "fs-extra-p"
import { safeLoad } from "js-yaml"
Expand Down
2 changes: 1 addition & 1 deletion test/src/BuildTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractFile } from "asar"
import { extractFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst"
import { Arch, BuildOptions, DIR_TARGET, Platform } from "electron-builder"
import { build, normalizeOptions } from "electron-builder/out/builder"
Expand Down
2 changes: 1 addition & 1 deletion test/src/extraMetadataTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractFile } from "asar"
import { extractFile } from "asar-electron-builder"
import { DIR_TARGET, Platform } from "electron-builder"
import * as path from "path"
import { assertThat } from "./helpers/fileAssert"
Expand Down
2 changes: 1 addition & 1 deletion test/src/globTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { statFile } from "asar"
import { statFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst"
import { DIR_TARGET, Platform } from "electron-builder"
import { mkdirs, outputFile, symlink, writeFile } from "fs-extra-p"
Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/winHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { extractFile } from "asar"
import { extractFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst"
import { Arch, Platform } from "electron-builder-core"
import { walk } from "electron-builder-util/out/fs"
Expand Down
28 changes: 18 additions & 10 deletions test/src/linux/debTest.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { Platform, Arch } from "electron-builder"
import { Arch, Platform } from "electron-builder"
import { readFile } from "fs-extra-p"
import { app } from "../helpers/packTester"

test.ifNotWindows("deb", app({targets: Platform.LINUX.createTarget("deb")}))

test.ifNotWindows("arm deb", app({targets: Platform.LINUX.createTarget("deb", Arch.armv7l)}))

test.ifNotWindows("custom depends", app({
targets: Platform.LINUX.createTarget("deb"),
config: {
deb: {
depends: ["foo"],
}
}
targets: Platform.LINUX.createTarget("deb"),
config: {
linux: {
executableName: "Boo",
},
deb: {
depends: ["foo"],
},
},
{
expectedDepends: "foo"
}))
effectiveOptionComputed: async (it) => {
const content = await readFile(it[1], "utf-8")
expect(content).toMatchSnapshot()
return false
}
}, {
expectedDepends: "foo",
}))
20 changes: 12 additions & 8 deletions test/src/linux/linuxPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ 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()
return false
},
config: {
linux: {
executableName: "foo",
executableName: "Foo",
desktop: {
Foo: "bar",
Terminal: "true",
},
}
}
},
effectiveOptionComputed: async (it) => {
const content = await readFile(it[1], "utf-8")
expect(content.includes("Foo=bar")).toBeTruthy()
expect(content.includes("Terminal=true")).toBeTruthy()
return false
},
}, {
projectDirCreated: it => remove(path.join(it, "build")),
packed: async context => {
const projectDir = context.getContent(Platform.LINUX)
await assertThat(path.join(projectDir, "foo")).isFile()
},
}))

// test prepacked asar also https://github.com/electron-userland/electron-builder/issues/1102
Expand Down
2 changes: 1 addition & 1 deletion typings/asar.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "asar" {
declare module "asar-electron-builder" {
interface AsarFileInfo {
offset: number
size: number
Expand Down
Loading

0 comments on commit d1c26e9

Please sign in to comment.