Skip to content

Commit

Permalink
fix(core): throw an error when no make targets for the given platform…
Browse files Browse the repository at this point in the history
… are found (#1515)
  • Loading branch information
malept authored Feb 25, 2020
1 parent 9f55a6c commit bc370aa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export default async ({

targets = targets.filter((_, i) => makers[i]);

if (targets.length === 0) {
throw new Error(`Could not find any make targets configured for the "${actualTargetPlatform}" platform.`);
}

info(interactive, `Making for the following targets: ${`${targets.map((t, i) => makers[i].name).join(', ')}`.cyan}`);

const packageJSON = await readMutatedPackageJson(dir, forgeConfig);
Expand Down
3 changes: 3 additions & 0 deletions packages/api/core/test/fixture/maker-wrong-platform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default class Maker {
platforms = ['win32'];
}
11 changes: 11 additions & 0 deletions packages/api/core/test/slow/api_spec_slow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ describe(`electron-forge API (with installer=${nodeInstaller})`, () => {
})).to.eventually.be.rejectedWith(/incompatible with this version/);
});

it('throws an error when no makers are configured for the given platform', async () => {
await expect(forge.make({
dir,
overrideTargets: [{
name: path.resolve(__dirname, '../fixture/maker-wrong-platform'),
}],
platform: 'linux',
skipPackage: true,
})).to.eventually.be.rejectedWith('Could not find any make targets configured for the "linux" platform.');
});

it('can make for the MAS platform successfully', async () => {
if (process.platform !== 'darwin') return;
await expect(forge.make({
Expand Down

0 comments on commit bc370aa

Please sign in to comment.