Skip to content

Commit

Permalink
fix(push-to-space): check for undefined/null and sys
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya committed Jan 2, 2018
1 parent 0ecb63d commit 3f3157e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/push/push-to-space.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export default function pushToSpace ({
// In case some entity throws an error, we null it in the list to avoid further processing.
// This functions removes the nulled entities from the lists.
function removeEmptyEntities (entityList) {
return entityList.filter((entity) => entity !== null)
return entityList.filter((entity) => !!entity || !entity.sys)
}

function archiveEntities (ctx, task, entities, sourceEntities) {
Expand All @@ -293,7 +293,7 @@ function archiveEntities (ctx, task, entities, sourceEntities) {
.map(({original}) => original.sys.id)

const entitiesToArchive = entities
.filter((entity) => entity && entityIdsToArchive.includes(entity.sys.id))
.filter((entity) => entityIdsToArchive.includes(entity.sys.id))

return publishing.archiveEntities(entitiesToArchive)
}
Expand All @@ -306,7 +306,7 @@ function publishEntities (ctx, task, entities, sourceEntities) {

// Filter imported entities and publish only these who got published in the source
const entitiesToPublish = entities
.filter((entity) => entity && entityIdsToPublish.includes(entity.sys.id))
.filter((entity) => entityIdsToPublish.includes(entity.sys.id))

return publishing.publishEntities(entitiesToPublish)
}

0 comments on commit 3f3157e

Please sign in to comment.