From 83298e246879ffa0e7eb78e64cac28f560b89b5d Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 18 Nov 2024 17:53:54 -0500 Subject: [PATCH] chore(agoric-cli): Condense `agoric wallet show` output Render empty purses/usedInvitations/offers on one line rather than three: ```diff { "purses": [ ["board0074",0] ], - "usedInvitations": [ - - ], - "offers": [ - - ] + "usedInvitations": [], + "offers": [] } ``` --- packages/agoric-cli/src/lib/format.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/agoric-cli/src/lib/format.js b/packages/agoric-cli/src/lib/format.js index e5e1a277d3c..d5e9d8836bb 100644 --- a/packages/agoric-cli/src/lib/format.js +++ b/packages/agoric-cli/src/lib/format.js @@ -100,14 +100,15 @@ export const purseBalanceTuples = (purses, assets) => { */ export const fmtRecordOfLines = record => { const { stringify } = JSON; + /** @type {Array<[string, string[]]>} */ const groups = Object.entries(record).map(([key, items]) => [ key, items.map(item => ` ${stringify(item)}`), ]); - const lineEntries = groups.map( - // @ts-expect-error ??? - ([key, lines]) => ` ${stringify(key)}: [\n${lines.join(',\n')}\n ]`, - ); + const lineEntries = groups.map(([key, lines]) => { + const linesStr = lines.length === 0 ? `[]` : `[\n${lines.join(',\n')}\n ]`; + return ` ${stringify(key)}: ${linesStr}`; + }); return `{\n${lineEntries.join(',\n')}\n}`; };