Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-240 electron: Allow passing all platform options to electron-builder #244

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ Each OS node contains properties that are used to identify what package to gener

Any properties that are undefined will fallback to default values.

You may include any additional per-platform properties as defined by `electron-builder` [here](https://www.electron.build/configuration/configuration#overridable-per-platform-options). These properties will be passed to `electron-builder`.

#### Adding a `package`

The `package` property is an array list of packages to be outputted. If the property is defined, the default packages are not used unless added. The order of the packages has no importance.
Expand Down
17 changes: 0 additions & 17 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ class ElectronBuilder {
continue;
}

/**
* Validate that the platform configuration properties provided are valid.
* Any invalid property will be warned and iggnored.
* If there is there are no valid properties
*/
if (!this.__validateUserPlatformBuildSettings(platformConfigs)) {
throw Error(`The platform "${platform}" contains an invalid property. Valid properties are: package, arch, signing`);
}

// Electron uses "win" as it's key, not "windows", so we will update here. We use windows in our settings for clarity.
this.__formatAppendUserSettings(
(platform === 'windows' ? 'win' : platform),
Expand Down Expand Up @@ -249,14 +240,6 @@ class ElectronBuilder {
}
}

__validateUserPlatformBuildSettings (platformConfigs) {
return !!(
platformConfigs.package ||
platformConfigs.arch ||
platformConfigs.signing
);
}

__appendMacUserSigning (config, buildConfigs) {
if (config.identity || process.env.CSC_LINK || process.env.CSC_NAME) buildConfigs.identity = config.identity || process.env.CSC_LINK || process.env.CSC_NAME;

Expand Down
32 changes: 0 additions & 32 deletions tests/spec/unit/lib/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -647,38 +647,6 @@ describe('Testing build.js:', () => {
expect(requireSpy).toHaveBeenCalled();
});

it('should throw new Error mac with incorrect platform build properties.', () => {
// mock platformConfig, buildConfig and buildOptions Objects
const platformConfig = {
mac: { pack: ['package', 'package2'], architecture: 'arch', sign: 'signing' }
};
const buildConfig = {
electron: platformConfig,
author: 'Apache',
name: 'Guy',
displayName: 'HelloWorld',
APP_BUILD_DIR: api.locations.build,
APP_BUILD_RES_DIR: api.locations.buildRes,
APP_WWW_DIR: api.locations.www
};

const buildOptions = { debug: false, buildConfig, argv: [] };

// create spies
existsSyncSpy = jasmine.createSpy('existsSync').and.returnValue(true);
requireSpy = jasmine.createSpy('require').and.returnValue(buildConfig);
build.__set__('fs', { existsSync: existsSyncSpy });
build.__set__({ require: requireSpy });

electronBuilder = new ElectronBuilder(buildOptions, api);

expect(existsSyncSpy).toHaveBeenCalled();
expect(requireSpy).toHaveBeenCalled();
expect(() => { electronBuilder.configureUserBuildSettings(); }).toThrow(
new Error('The platform "mac" contains an invalid property. Valid properties are: package, arch, signing')
);
});

it('should set configureUserBuildSettings for when using windows instead of win.', () => {
// mock platformConfig, buildConfig and buildOptions Objects
const platformConfig = {
Expand Down