From 7c333c9c5471932c7da8e7c0230c421592674168 Mon Sep 17 00:00:00 2001 From: nedsalk Date: Mon, 13 Jan 2025 17:36:08 +0100 Subject: [PATCH] make `withConfig` async again --- packages/fuels/src/cli/commands/dev/index.test.ts | 2 +- packages/fuels/src/cli/commands/dev/index.ts | 2 +- packages/fuels/src/cli/commands/node/index.test.ts | 2 +- packages/fuels/src/cli/commands/withConfig.ts | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/fuels/src/cli/commands/dev/index.test.ts b/packages/fuels/src/cli/commands/dev/index.test.ts index 08714a75590..f950daff5b4 100644 --- a/packages/fuels/src/cli/commands/dev/index.test.ts +++ b/packages/fuels/src/cli/commands/dev/index.test.ts @@ -35,7 +35,7 @@ describe('dev', () => { const withConfigErrorHandler = vi .spyOn(withConfigMod, 'withConfigErrorHandler') - .mockReturnValue(undefined as never); + .mockReturnValue(Promise.resolve()); const loadConfig = vi .spyOn(loadConfigMod, 'loadConfig') diff --git a/packages/fuels/src/cli/commands/dev/index.ts b/packages/fuels/src/cli/commands/dev/index.ts index 0b894209a05..bd62eaecbda 100644 --- a/packages/fuels/src/cli/commands/dev/index.ts +++ b/packages/fuels/src/cli/commands/dev/index.ts @@ -53,7 +53,7 @@ export const configFileChanged = (state: DevState) => async (_event: string, pat // eslint-disable-next-line @typescript-eslint/no-use-before-define await dev(await loadConfig(state.config.basePath)); } catch (err: unknown) { - withConfigErrorHandler(err, state.config); + await withConfigErrorHandler(err, state.config); } }; diff --git a/packages/fuels/src/cli/commands/node/index.test.ts b/packages/fuels/src/cli/commands/node/index.test.ts index 96e7554fb26..659c65c40af 100644 --- a/packages/fuels/src/cli/commands/node/index.test.ts +++ b/packages/fuels/src/cli/commands/node/index.test.ts @@ -25,7 +25,7 @@ describe('node', () => { const withConfigErrorHandler = vi .spyOn(withConfigMod, 'withConfigErrorHandler') - .mockReturnValue(undefined as never); + .mockReturnValue(Promise.resolve()); const loadConfig = vi .spyOn(loadConfigMod, 'loadConfig') diff --git a/packages/fuels/src/cli/commands/withConfig.ts b/packages/fuels/src/cli/commands/withConfig.ts index 7d9ac542eb9..649480d9818 100644 --- a/packages/fuels/src/cli/commands/withConfig.ts +++ b/packages/fuels/src/cli/commands/withConfig.ts @@ -5,9 +5,9 @@ import { loadConfig } from '../config/loadConfig'; import type { Commands, FuelsConfig, CommandEvent } from '../types'; import { error, log } from '../utils/logger'; -export const withConfigErrorHandler = (err: Error, config?: FuelsConfig) => { +export const withConfigErrorHandler = async (err: Error, config?: FuelsConfig): Promise => { error(err.message); - config?.onFailure?.(config, err); + await config?.onFailure?.(config, err); throw err; }; @@ -27,7 +27,7 @@ export function withConfig( try { config = await loadConfig(options.path); } catch (err) { - withConfigErrorHandler(err); + await withConfigErrorHandler(err); return; } @@ -35,7 +35,7 @@ export function withConfig( await fn(config, program); log(`🎉 ${capitalizeString(command)} completed successfully!`); } catch (err: unknown) { - withConfigErrorHandler(err, config); + await withConfigErrorHandler(err, config); } }; }