From 548ab4646bd1e2d79dbda0609551e6f805b69d09 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 30 Aug 2021 14:04:13 -0600 Subject: [PATCH] fix: update exports --- src/exported.ts | 4 ++-- src/hooks.ts | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/exported.ts b/src/exported.ts index b4899080..499b3767 100644 --- a/src/exported.ts +++ b/src/exported.ts @@ -8,5 +8,5 @@ export { generateTableChoices } from './util'; export { Deployable, Deployer } from './deployer'; export { Prompter } from './prompter'; -export { runHook, SfHook } from './hooks'; -export { JsonObject, TableObject } from './types'; +export { SfHook } from './hooks'; +export * from './types'; diff --git a/src/hooks.ts b/src/hooks.ts index 925c9aa1..44b5b13d 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -21,23 +21,25 @@ interface SfHooks extends Hooks { type GenericHook = Hook>; +export class SfHook { + public static async run( + config: Config, + hookName: T, + options: SfHooks[T]['options'] = {} + ): Promise> { + const timeout = Duration.milliseconds(env.getNumber('SF_HOOK_TIMEOUT_MS') || 5000); + const results = await config.runHook(hookName, options, timeout.milliseconds); + results.failures.forEach((failure) => { + cli.debug(`Failed to run ${hookName} hook for ${failure.plugin.name}`); + cli.debug(failure.error.toString()); + }); + return results; + } +} + export namespace SfHook { export type EnvList = GenericHook<'sf:env:list', T>; export type EnvDisplay = GenericHook<'sf:env:display', T>; export type Deploy = GenericHook<'sf:deploy', T>; export type Login = Hook<'sf:login', SfHooks>; } - -export async function runHook( - config: Config, - hookName: T, - options: SfHooks[T]['options'] = {} -): Promise> { - const timeout = Duration.milliseconds(env.getNumber('SF_HOOK_TIMEOUT_MS') || 5000); - const results = await config.runHook(hookName, options, timeout.milliseconds); - results.failures.forEach((failure) => { - cli.debug(`Failed to run ${hookName} hook for ${failure.plugin.name}`); - cli.debug(failure.error.toString()); - }); - return results; -}