From 253cd5f42340ab07ae3c9782ffcc1c30c12dfb08 Mon Sep 17 00:00:00 2001 From: Ulad Kasach Date: Fri, 11 Oct 2024 07:07:21 -0400 Subject: [PATCH] fix(types): expose CommandContext shape --- src/asCommand.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/asCommand.ts b/src/asCommand.ts index 85bb488..76ee06c 100644 --- a/src/asCommand.ts +++ b/src/asCommand.ts @@ -6,6 +6,19 @@ import type { LogMethods } from 'simple-leveled-log-methods'; const bottleneckFileLog = new Bottleneck({ maxConcurrency: 1 }); +/** + * context provided by the command + */ +export interface CommandContext { + log: LogMethods; + out: { + write: (file: { + name: string; + data: Parameters[1]; + }) => Promise<{ path: string }>; + }; +} + /** * converts any function into a pit-of-success command * @@ -29,15 +42,7 @@ export const asCommand = }, logic: ( input: I, - control: { - log: LogMethods; - out: { - write: (file: { - name: string; - data: Parameters[1]; - }) => Promise<{ path: string }>; - }; - }, + context: CommandContext, ) => Promise, ) => async (input: I): Promise => {