Skip to content

Commit

Permalink
feat: allow disabling maker in config (#2754)
Browse files Browse the repository at this point in the history
* feat: allow disabling maker in config

* fix test

* `disabled` -> `enabled`
  • Loading branch information
erickzhao committed Jun 9, 2022
1 parent 412327a commit 6977740
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ export default async ({
if ((target as MakerBase<any>).__isElectronForgeMaker) {
maker = target as MakerBase<any>;
/* eslint-enable @typescript-eslint/no-explicit-any */
// eslint-disable-next-line no-continue
if (!maker.platforms.includes(actualTargetPlatform)) continue;
} else {
const resolvableTarget: IForgeResolvableMaker = target as IForgeResolvableMaker;
// non-false falsy values should be 'true'
if (resolvableTarget.enabled === false) continue;

if (!resolvableTarget.name) {
throw new Error(`The following maker config is missing a maker name: ${JSON.stringify(resolvableTarget)}`);
Expand Down
17 changes: 17 additions & 0 deletions packages/api/core/test/fast/make_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,21 @@ describe('make', () => {
).to.eventually.be.rejectedWith(/^The following maker config has a maker name that is not a string:/);
});
});

it('can skip makers via config', async () => {
const stubbedMake = proxyquire.noCallThru().load('../../src/api/make', {
'../util/read-package-json': {
readMutatedPackageJson: () => Promise.resolve(require('../fixture/app-with-maker-disable/package.json')),
},
}).default;
await expect(
stubbedMake({
arch: 'x64',
dir: path.join(fixtureDir, 'app-with-maker-disable'),
platform: 'linux',
skipPackage: true,
})
).to.eventually.be.rejectedWith(/Could not find any make targets configured for the "linux" platform./);
proxyquire.callThru();
});
});
Empty file.
19 changes: 19 additions & 0 deletions packages/api/core/test/fixture/app-with-maker-disable/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "test",
"config": {
"forge": {
"makers": [
{
"name": "@electron-forge/maker-zip",
"enabled": false,
"platforms": [
"linux"
]
}
]
}
},
"devDependencies": {
"electron": "^1000.0.0"
}
}
1 change: 1 addition & 0 deletions packages/utils/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface IForgePlugin {
}

export interface IForgeResolvableMaker {
enabled: boolean;
name: string;
platforms: ForgePlatform[] | null;
config: any; // eslint-disable-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 6977740

Please sign in to comment.