Skip to content

Commit 3132610

Browse files
committed
feat: specify path to custom Electron build (Electron.app)
Closes #760
1 parent f0b38d9 commit 3132610

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ language: c
1616
cache:
1717
directories:
1818
- node_modules
19+
- nsis-auto-updater/node_modules
1920
- $HOME/.electron
2021

2122
before_install:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# electron-builder [![npm version](https://img.shields.io/npm/v/electron-builder.svg)](https://npmjs.org/package/electron-builder) [![donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W6V79R2RGCCHL)
2-
A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with "auto update" support out of the box.
2+
A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with auto update support out of the box.
33

44
* NPM packages management:
55
* [Native application dependencies](http://electron.atom.io/docs/latest/tutorial/using-native-node-modules/) compilation (only if the [two-package.json project structure](#two-packagejson-structure) is used).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "electron-builder",
3-
"description": "Complete solution to build ready for distribution and 'auto update' Electron App installers",
3+
"description": "A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box",
44
"version": "0.0.0-semantic-release",
55
"main": "out/index.js",
66
"files": [

src/metadata.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ export interface BuildMetadata {
200200
*/
201201
readonly nodeGypRebuild?: boolean
202202

203+
/**
204+
The path to custom Electron build (e.g. `~/electron/out/R`). Only macOS supported, file issue if need for Linux or Windows.
205+
*/
206+
readonly electronDist?: string
207+
203208
readonly icon?: string | null
204209

205210
// deprecated

src/packager/dirPackager.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Promise as BluebirdPromise } from "bluebird"
2-
import { emptyDir } from "fs-extra-p"
2+
import { emptyDir, copy } from "fs-extra-p"
33
import { warn } from "../util/log"
44
import { PlatformPackager } from "../platformPackager"
5+
import { debug7zArgs, spawn } from "../util/util"
6+
import { path7za } from "7zip-bin"
7+
import * as path from "path"
58

69
const downloadElectron: (options: any) => Promise<any> = BluebirdPromise.promisify(require("electron-download"))
7-
const extract: any = BluebirdPromise.promisify(require("extract-zip"))
810

911
//noinspection JSUnusedLocalSymbols
1012
const __awaiter = require("../util/awaiter")
@@ -29,11 +31,19 @@ function subOptionWarning (properties: any, optionName: any, parameter: any, val
2931
}
3032

3133
export async function pack(packager: PlatformPackager<any>, out: string, platform: string, arch: string, electronVersion: string, initializeApp: () => Promise<any>) {
32-
const zipPath = (await BluebirdPromise.all<any>([
33-
downloadElectron(createDownloadOpts(packager.devMetadata.build, platform, arch, electronVersion)),
34-
emptyDir(out)
35-
]))[0]
36-
await extract(zipPath, {dir: out})
34+
const electronDist = packager.devMetadata.build.electronDist
35+
if (electronDist == null) {
36+
const zipPath = (await BluebirdPromise.all<any>([
37+
downloadElectron(createDownloadOpts(packager.devMetadata.build, platform, arch, electronVersion)),
38+
emptyDir(out)
39+
]))[0]
40+
41+
await spawn(path7za, debug7zArgs("x").concat(zipPath, `-o${out}`))
42+
}
43+
else {
44+
await emptyDir(out)
45+
await copy(path.resolve(packager.info.projectDir, electronDist, "Electron.app"), path.join(out, "Electron.app"))
46+
}
3747

3848
if (platform === "darwin" || platform === "mas") {
3949
await(<any>require("./mac")).createApp(packager, out, initializeApp)

test/src/macPackagerTest.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from "./helpers/avaEx"
2-
import { assertPack, platform, modifyPackageJson, signed, app } from "./helpers/packTester"
2+
import { assertPack, platform, modifyPackageJson, signed, app, appThrows } from "./helpers/packTester"
33
import OsXPackager from "out/macPackager"
44
import { move, writeFile, deleteFile, remove } from "fs-extra-p"
55
import * as path from "path"
@@ -11,6 +11,7 @@ import { SignOptions, FlatOptions } from "electron-osx-sign-tf"
1111
import { Arch } from "out"
1212
import { Target } from "out/platformPackager"
1313
import { DmgTarget } from "out/targets/dmg"
14+
import { DIR_TARGET } from "out/targets/targetFactory"
1415

1516
//noinspection JSUnusedLocalSymbols
1617
const __awaiter = require("out/util/awaiter")
@@ -204,6 +205,14 @@ test.ifOsx("disable dmg icon, bundleVersion", () => {
204205
})
205206
})
206207

208+
test.ifOsx("electronDist", appThrows(/ENOENT: no such file or directory/, {
209+
targets: Platform.OSX.createTarget(DIR_TARGET),
210+
}, {
211+
projectDirCreated: projectDir => modifyPackageJson(projectDir, data => {
212+
data.build.electronDist = "foo"
213+
})
214+
}))
215+
207216
class CheckingMacPackager extends OsXPackager {
208217
effectiveDistOptions: any
209218
effectiveSignOptions: SignOptions

0 commit comments

Comments
 (0)