Skip to content

Commit

Permalink
Merge pull request #20 from WyriHaximusNet/support-more-than-one-obje…
Browse files Browse the repository at this point in the history
…ct-in-events

Support more than one object in events
  • Loading branch information
WyriHaximus authored Jan 16, 2021
2 parents c111e2f + 5518d4c commit 5c98b44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion hooks/add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ else
type=$(jq -r '.[0].type' ${BINDING_CONTEXT_PATH})
echo "Event: ${type}"
if [[ $type == "Event" ]] ; then
/engine/add.sh $(jq -r -c '.[0].object' ${BINDING_CONTEXT_PATH})
while IFS= read -r object; do
/engine/add.sh "$object"
done< <(jq -c '.[].object' < ${BINDING_CONTEXT_PATH})
fi
fi
6 changes: 4 additions & 2 deletions hooks/start-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ else
echo "Event: ${type}"
if [[ $type == "Synchronization" ]] ; then
/engine/init-global-database.sh
count=$(jq -c '.[0].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | wc -l)
count=$(jq -c '.[].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | wc -l)
if [[ "$count" != "0" ]] ; then
echo "Synchronizing existing redis databases"
jq -c '.[0].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | tr '\n' '\0' | xargs -0 /engine/add.sh
while IFS= read -r object; do
/engine/add.sh "$object"
done< <(jq -c '.[].objects | .[] | .object' < ${BINDING_CONTEXT_PATH})
fi
fi
fi

0 comments on commit 5c98b44

Please sign in to comment.