Skip to content

Commit

Permalink
chore(require-search): make error message clearer (#3037)
Browse files Browse the repository at this point in the history
  • Loading branch information
erickzhao authored Nov 1, 2022
1 parent e1d5db0 commit 584a63b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default async ({
await asyncOra('Resolving Forge Config', async () => {
const resolvedDir = await resolveDir(dir);
if (!resolvedDir) {
throw new Error('Failed to locate makeable Electron application');
throw new Error(`Failed to locate makeable Electron application at ${dir}`);
}
dir = resolvedDir;

Expand All @@ -106,7 +106,7 @@ export default async ({
const actualTargetPlatform = platform;
platform = platform === 'mas' ? 'darwin' : platform;
if (!['darwin', 'win32', 'linux', 'mas'].includes(actualTargetPlatform)) {
throw new Error(`'${actualTargetPlatform}' is an invalid platform. Choices are 'darwin', 'mas', 'win32' or 'linux'`);
throw new Error(`'${actualTargetPlatform}' is an invalid platform. Choices are 'darwin', 'mas', 'win32' or 'linux'.`);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -134,7 +134,9 @@ export default async ({

const MakerClass = requireSearch<typeof MakerImpl>(dir, [resolvableTarget.name]);
if (!MakerClass) {
throw new Error(`Could not find module with name: ${resolvableTarget.name}. Make sure it's listed in the devDependencies of your package.json`);
throw new Error(
`Could not find module with name '${resolvableTarget.name}'. If this is a package from NPM, make sure it's listed in the devDependencies of your package.json. If this is a local module, make sure you have the correct path to its entry point. Try using the DEBUG="electron-forge:require-search" environment variable for more information.`
);
}

maker = new MakerClass(resolvableTarget.config, resolvableTarget.platforms || undefined);
Expand All @@ -145,14 +147,14 @@ export default async ({
throw new Error(
[
`Maker for target ${maker.name} is incompatible with this version of `,
'electron-forge, please upgrade or contact the maintainer ',
'Electron Forge, please upgrade or contact the maintainer ',
"(needs to implement 'isSupportedOnCurrentPlatform)')",
].join('')
);
}

if (!maker.isSupportedOnCurrentPlatform()) {
throw new Error([`Cannot make for ${platform} and target ${maker.name}: the maker declared `, `that it cannot run on ${process.platform}`].join(''));
throw new Error(`Cannot make for ${platform} and target ${maker.name}: the maker declared that it cannot run on ${process.platform}.`);
}

maker.ensureExternalBinariesExist();
Expand Down

0 comments on commit 584a63b

Please sign in to comment.