Skip to content

Commit

Permalink
feat: local path to custom electron build (windows support)
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaDima committed May 7, 2017
1 parent dcd0e17 commit 4e33c70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/electron-builder/src/packager/dirPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -55,8 +55,9 @@ async function unpack(packager: PlatformPackager<any>, 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") {
Expand Down
8 changes: 8 additions & 0 deletions packages/electron-builder/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,14 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
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")
}
Expand Down
9 changes: 8 additions & 1 deletion test/src/windows/winPackagerTest.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -69,4 +69,11 @@ describe.ifAll("sign", () => {
forceCodeSigning: true,
}
}))

test.ifNotCiMac("electronDist", appThrows({
targets: Platform.WINDOWS.createTarget(DIR_TARGET),
config: {
electronDist: "foo",
}
}))
})

0 comments on commit 4e33c70

Please sign in to comment.