diff --git a/packages/electron-builder/src/packager/dirPackager.ts b/packages/electron-builder/src/packager/dirPackager.ts index 74ee48aa594..1be80bb11dd 100644 --- a/packages/electron-builder/src/packager/dirPackager.ts +++ b/packages/electron-builder/src/packager/dirPackager.ts @@ -2,7 +2,7 @@ import { path7za } from "7zip-bin" import BluebirdPromise from "bluebird-lst" import { debug7zArgs, spawn } from "electron-builder-util" import { copyDir } from "electron-builder-util/out/fs" -import { warn } from "electron-builder-util/out/log" +import { warn, log } from "electron-builder-util/out/log" import { chmod, emptyDir } from "fs-extra-p" import * as path from "path" import { PlatformPackager } from "../platformPackager" @@ -55,8 +55,9 @@ async function unpack(packager: PlatformPackager, out: string, platform: st await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`)) } else { + log(`Copying Electron from ` + packager.getElectronSrcDir(dist) + ` to ` + packager.getElectronDestDir(out)) await emptyDir(out) - await copyDir(path.resolve(packager.info.projectDir, dist, "Electron.app"), path.join(out, "Electron.app")) + await copyDir(packager.getElectronSrcDir(dist), packager.getElectronDestDir(out)) } if (platform === "linux") { diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts index 2e46d454533..f568269a637 100644 --- a/packages/electron-builder/src/platformPackager.ts +++ b/packages/electron-builder/src/platformPackager.ts @@ -272,6 +272,14 @@ export abstract class PlatformPackager return deepAssign({}, result) } + public getElectronSrcDir(appSrcDir: string): string { + return this.platform === Platform.MAC ? path.join(this.projectDir, appSrcDir, "Electron.app") : path.join(this.projectDir, appSrcDir) + } + + public getElectronDestDir(appOutDir: string): string { + return this.platform === Platform.MAC ? path.join(appOutDir, "Electron.app") : appOutDir + } + public getResourcesDir(appOutDir: string): string { return this.platform === Platform.MAC ? this.getMacOsResourcesDir(appOutDir) : path.join(appOutDir, "resources") } diff --git a/test/src/windows/winPackagerTest.ts b/test/src/windows/winPackagerTest.ts index a8f07886aab..c89be9d0906 100644 --- a/test/src/windows/winPackagerTest.ts +++ b/test/src/windows/winPackagerTest.ts @@ -1,4 +1,4 @@ -import { Platform } from "electron-builder" +import { DIR_TARGET, Platform } from "electron-builder" import { rename, unlink, writeFile } from "fs-extra-p" import * as path from "path" import { CheckingWinPackager } from "../helpers/CheckingPackager" @@ -69,4 +69,11 @@ describe.ifAll("sign", () => { forceCodeSigning: true, } })) + + test.ifNotCiMac("electronDist", appThrows({ + targets: Platform.WINDOWS.createTarget(DIR_TARGET), + config: { + electronDist: "foo", + } + })) }) \ No newline at end of file