diff --git a/src/platformPackager.ts b/src/platformPackager.ts index 752530d6f65..77915292e22 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -151,8 +151,18 @@ export abstract class PlatformPackager abstract pack(outDir: string, arch: Arch, targets: Array, postAsyncTasks: Array>): Promise protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: Arch, customBuildOptions: DC) { - await this.packApp(options, appOutDir) + await pack(options) await this.copyExtraFiles(appOutDir, arch, customBuildOptions) + + const afterPack = this.devMetadata.build.afterPack + if (afterPack != null) { + await afterPack({ + appOutDir: appOutDir, + options: options, + }) + } + + await this.sanityCheckPackage(appOutDir, options.asar) } protected computePackOptions(outDir: string, appOutDir: string, arch: Arch): ElectronPackagerOptions { @@ -195,20 +205,6 @@ export abstract class PlatformPackager return options } - protected async packApp(options: ElectronPackagerOptions, appOutDir: string): Promise { - await pack(options) - - const afterPack = this.devMetadata.build.afterPack - if (afterPack != null) { - await afterPack({ - appOutDir: appOutDir, - options: options, - }) - } - - await this.sanityCheckPackage(appOutDir, options.asar) - } - private getExtraResources(isResources: boolean, arch: Arch, customBuildOptions: DC): Promise> { const buildMetadata: any = this.devMetadata.build let extra: Array | n = buildMetadata == null ? null : buildMetadata[isResources ? "extraResources" : "extraFiles"] diff --git a/src/util.ts b/src/util.ts index 39066b9b89e..ba4884b92c4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -215,7 +215,8 @@ export function debug7zArgs(command: "a" | "x"): Array { } let tmpDirCounter = 0 +const pidAsString = process.pid.toString(36) export function getTempName(prefix?: string | n): string { - return `${prefix == null ? "" : prefix + "-"}${process.pid}-${tmpDirCounter++}` + return `${prefix == null ? "" : prefix + "-"}${pidAsString}-${tmpDirCounter++}-${Date.now().toString(36)}` } \ No newline at end of file diff --git a/src/winPackager.ts b/src/winPackager.ts index 087660ec952..3926631c111 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -76,16 +76,17 @@ export class WinPackager extends PlatformPackager { return path.join(outDir, `win${getArchSuffix(arch)}-unpacked`) } - protected async packApp(options: any, appOutDir: string) { - await super.packApp(options, appOutDir) + protected async doPack(options: ElectronPackagerOptions, outDir: string, appOutDir: string, arch: Arch, customBuildOptions: WinBuildOptions) { + await super.doPack(options, outDir, appOutDir, arch, customBuildOptions) - if (process.platform !== "linux" && this.options.cscLink != null && this.options.cscKeyPassword != null) { - const filename = this.appName + ".exe" + const cert = await this.certFilePromise + if (cert != null) { + const filename = `${this.appName}.exe` log(`Signing ${filename}`) await BluebirdPromise.promisify(sign)({ path: path.join(appOutDir, filename), - cert: (await this.certFilePromise)!, - password: this.options.cscKeyPassword, + cert: cert, + password: this.options.cscKeyPassword!, name: this.appName, site: await this.computePackageUrl(), overwrite: true, diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 37aea81e0ea..b800f51af28 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -5,7 +5,7 @@ import { parse as parsePlist } from "plist" import { CSC_LINK, CSC_KEY_PASSWORD, CSC_INSTALLER_LINK, CSC_INSTALLER_KEY_PASSWORD } from "./codeSignData" import { expectedLinuxContents, expectedWinContents } from "./expectedContents" import { Packager, PackagerOptions, Platform, getProductName, ArtifactCreated, Arch, DIR_TARGET } from "out" -import { exec } from "out/util" +import { exec, getTempName } from "out/util" import { tmpdir } from "os" import DecompressZip = require("decompress-zip") import { getArchSuffix } from "out/platformPackager" @@ -14,9 +14,6 @@ import pathSorter = require("path-sort") //noinspection JSUnusedLocalSymbols const __awaiter = require("out/awaiter") -const tmpDirPrefix = "electron-builder-test-" + process.pid + "-" -let tmpDirCounter = 0 - if (process.env.TRAVIS !== "true") { // we don't use CircleCI, so, we can safely set this env process.env.CIRCLE_BUILD_NUM = 42 @@ -42,7 +39,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO const customTmpDir = process.env.TEST_APP_TMP_DIR if (useTempDir) { // non-osx test uses the same dir as osx test, but we cannot share node_modules (because tests executed in parallel) - const dir = customTmpDir == null ? path.join(tmpdir(), `${tmpDirPrefix}${fixtureName}-${tmpDirCounter++}`) : path.resolve(customTmpDir) + const dir = customTmpDir == null ? path.join(tmpdir(), `${getTempName("electron-builder-test")}-${fixtureName}}`) : path.resolve(customTmpDir) if (customTmpDir != null) { console.log("Custom temp dir used: %s", customTmpDir) } diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index cc237420402..190254cdbc0 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -18,6 +18,11 @@ test.ifNotCiOsx("win", () => assertPack("test-app-one", signed({ }) )) +test.ifNotCiOsx("win 32", () => assertPack("test-app-one", signed({ + targets: Platform.WINDOWS.createTarget(null, Arch.ia32), + }) +)) + // very slow test.ifWinCi("delta", () => assertPack("test-app-one", { targets: Platform.WINDOWS.createTarget(null, Arch.ia32),