From 584a63b3a442e979192dbd08de1c16a019f10505 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Mon, 31 Oct 2022 17:21:42 -0700 Subject: [PATCH] chore(require-search): make error message clearer (#3037) --- packages/api/core/src/api/make.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/api/core/src/api/make.ts b/packages/api/core/src/api/make.ts index edefe796b9..6a13adacde 100644 --- a/packages/api/core/src/api/make.ts +++ b/packages/api/core/src/api/make.ts @@ -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; @@ -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 @@ -134,7 +134,9 @@ export default async ({ const MakerClass = requireSearch(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); @@ -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();