From 2dddfa7255329c67bdc57929119589ee6a7f60c0 Mon Sep 17 00:00:00 2001 From: timdeluxe <5765175+timdeluxe@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:00:21 +0100 Subject: [PATCH] fix: More resistance againts empty json blocks or properties --- src/commands/cleanup.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/commands/cleanup.ts b/src/commands/cleanup.ts index 35f4647..d25b8e1 100644 --- a/src/commands/cleanup.ts +++ b/src/commands/cleanup.ts @@ -189,7 +189,10 @@ export default class extends Command { } } ) - output.push(...response.data.items) + // do not push empty items + if(Object.keys(response.data.items).length) { + output.push(...response.data.items) + } this.logger.debug(`page ${i} and token = +++${response.data.continuationToken}+++`) if (response.data.continuationToken != null) { continuationToken = response.data.continuationToken @@ -208,17 +211,20 @@ export default class extends Command { const components: Array = [] const paths: Array = [] for (let item of output) { - let trimmedPath : string = item.assets[0].path.split("/").slice(0, pathDepth).join("/") - components.push(new Component() - .withDate(item.assets[0].lastModified) - .withId(item.id) - .withVersion(item.version) - .withPath(trimmedPath) - ) - if (!paths.includes(trimmedPath)) { - paths.push(trimmedPath) + // skip if first asset has no path + if(item.assets[0].hasOwnProperty('path')) { + let trimmedPath: string = item.assets[0].path.split("/").slice(0, pathDepth).join("/") + components.push(new Component() + .withDate(item.assets[0].lastModified) + .withId(item.id) + .withVersion(item.version) + .withPath(trimmedPath) + ) + if (!paths.includes(trimmedPath)) { + paths.push(trimmedPath) + } + this.logger.debug(JSON.stringify(item.version)) } - this.logger.debug(JSON.stringify(item.version)) } /**