Skip to content

Commit

Permalink
feat: allow disabling maker in config
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao committed Mar 3, 2022
1 parent 204ec25 commit ef05dda
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ 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;
if (resolvableTarget.disabled) continue;

if (!resolvableTarget.name) {
throw new Error(`The following maker config is missing a maker name: ${JSON.stringify(resolvableTarget)}`);
Expand Down
16 changes: 16 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,20 @@ 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-skip/package.json')),
},
}).default;
await expect(
stubbedMake({
arch: 'x64',
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-skip/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",
"skip": true,
"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 {
disabled: boolean;
name: string;
platforms: ForgePlatform[] | null;
config: any; // eslint-disable-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit ef05dda

Please sign in to comment.