diff --git a/templates/cli/lib/parser.ts b/templates/cli/lib/parser.ts index 01959fbb1d..e916998d58 100644 --- a/templates/cli/lib/parser.ts +++ b/templates/cli/lib/parser.ts @@ -199,6 +199,7 @@ const maskSensitiveData = ( const filterObject = (obj: JsonObject): JsonObject => { const result: JsonObject = {}; + if (obj == null) return result; for (const key of Object.keys(obj)) { const value = obj[key]; if (typeof value === "function") continue; @@ -340,13 +341,15 @@ export const parse = (data: unknown): void => { } if (Array.isArray(section.value)) { - const sectionTitle = - typeof section.value[0] === "object" + const hasObjects = section.value.some( + (item) => item !== null && typeof item === "object", + ); + const sectionTitle = hasObjects ? `${section.key} (${section.value.length})` : section.key; console.log(`${chalk.yellow.bold.underline(sectionTitle)}`); - if (typeof section.value[0] === "object") { + if (hasObjects) { drawTable(section.value, { indent: " ", sectionName: section.key }); } else { drawScalarArray(section.value, { indent: " " });