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

fix(core): throw an error when no make targets for the given platform are found #1515

Merged
merged 2 commits into from
Feb 25, 2020
Merged
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
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