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
Close #1534, Close #1342
  • Loading branch information
MariaDima authored and develar committed May 8, 2017
1 parent d8aa078 commit 521aea6
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,12 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
args.push(outFile)
return await exec("productbuild", args)
}

public getElectronSrcDir(dist: string) {
return path.resolve(this.projectDir, dist, this.electronDistMacOsAppName)
}

public getElectronDestDir(appOutDir: string) {
return path.join(appOutDir, this.electronDistMacOsAppName)
}
}
7 changes: 5 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 { log, warn } 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,11 @@ async function unpack(packager: PlatformPackager<any>, out: string, platform: st
await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
}
else {
const source = packager.getElectronSrcDir(dist)
const destination = packager.getElectronDestDir(out)
log(`Copying Electron from "${source}" to "${destination}"`)
await emptyDir(out)
await copyDir(path.resolve(packager.info.projectDir, dist, "Electron.app"), path.join(out, "Electron.app"))
await copyDir(source, destination)
}

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(dist: string): string {
return path.resolve(this.projectDir, dist)
}

public getElectronDestDir(appOutDir: string): string {
return appOutDir
}

public getResourcesDir(appOutDir: string): string {
return this.platform === Platform.MAC ? this.getMacOsResourcesDir(appOutDir) : path.join(appOutDir, "resources")
}
Expand Down
2 changes: 2 additions & 0 deletions test/out/windows/__snapshots__/winPackagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ exports[`icon not an image 1`] = `"Windows icon is not valid ico file, please fi
exports[`sign certificateSha1 1`] = `"certificateSha1 supported only on Windows"`;
exports[`sign electronDist 1`] = `"ENOENT: no such file or directory, scandir '<path>/foo'"`;
exports[`sign ev 1`] = `"certificateSubjectName supported only on Windows"`;
exports[`sign forceCodeSigning 1`] = `"App is not signed and \\"forceCodeSigning\\" is set to true, please ensure that code signing configuration is correct, please see https://github.com/electron-userland/electron-builder/wiki/Code-Signing"`;
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 521aea6

Please sign in to comment.