From 1cc7e0738de190805cccd5404674df2b6ab5a7de Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 30 Dec 2022 13:54:43 -0600 Subject: [PATCH] fix: revert pr #33 (caused downstream type problems) --- src/util.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util.ts b/src/util.ts index 8ee919318..baafcda55 100644 --- a/src/util.ts +++ b/src/util.ts @@ -14,15 +14,11 @@ import { SUPPORTED_ENV_VARS, Messages, } from '@salesforce/core'; +import { HelpSection, HelpSectionKeyValueTable } from '@oclif/core'; Messages.importMessagesDirectory(__dirname); const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages'); -export type HelpSection = { - header: string; - body: Array<{ name: string; description: string } | undefined>; -}; - /** * Function to build a help section for command help. * Takes a string to be used as section header text and an array of enums @@ -58,10 +54,13 @@ export function toHelpSection( return Object.entries(v).map(([name, description]) => ({ name, description })); } }) - .filter((b) => b); + .filter(isHelpSectionBodyEntry); return { header, body }; } +const isHelpSectionBodyEntry = (entry: unknown): entry is HelpSectionKeyValueTable[number] => + typeof entry === 'object' && entry !== null && 'name' in entry && 'description' in entry; + export function parseVarArgs(args: Record, argv: string[]): Record { const final: Record = {}; const argVals = Object.values(args);