From 0321093e4f8a0f659346a9e2e808ad44c6d3771f Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Wed, 18 Oct 2023 08:11:12 -0600 Subject: [PATCH] fix: handle ModuleLoadError from hooks --- src/config/config.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/config/config.ts b/src/config/config.ts index a3fcef2b7..78df047bd 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -528,7 +528,17 @@ export class Config implements IConfig { } catch (error: any) { final.failures.push({error: error as Error, plugin: p}) debug(error) - if (!captureErrors && error.oclif?.exit !== undefined) throw error + // Do not throw the error if + // captureErrors is set to true + // error.oclif.exit is undefined or 0 + // error.code is MODULE_NOT_FOUND + if ( + !captureErrors && + error.oclif?.exit !== undefined && + error.oclif?.exit !== 0 && + error.code !== 'MODULE_NOT_FOUND' + ) + throw error } marker?.addDetails({