Skip to content

Commit

Permalink
fix: More resistance againts empty json blocks or properties
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeluxe committed Feb 7, 2024
1 parent 589fce4 commit 2dddfa7
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/commands/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -208,17 +211,20 @@ export default class extends Command {
const components: Array<Component> = []
const paths: Array<string> = []
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))
}

/**
Expand Down

0 comments on commit 2dddfa7

Please sign in to comment.