Skip to content

Commit 5c98b44

Browse files
authored
Merge pull request #20 from WyriHaximusNet/support-more-than-one-object-in-events
Support more than one object in events
2 parents c111e2f + 5518d4c commit 5c98b44

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

hooks/add.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ else
1515
type=$(jq -r '.[0].type' ${BINDING_CONTEXT_PATH})
1616
echo "Event: ${type}"
1717
if [[ $type == "Event" ]] ; then
18-
/engine/add.sh $(jq -r -c '.[0].object' ${BINDING_CONTEXT_PATH})
18+
while IFS= read -r object; do
19+
/engine/add.sh "$object"
20+
done< <(jq -c '.[].object' < ${BINDING_CONTEXT_PATH})
1921
fi
2022
fi

hooks/start-up.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ else
1616
echo "Event: ${type}"
1717
if [[ $type == "Synchronization" ]] ; then
1818
/engine/init-global-database.sh
19-
count=$(jq -c '.[0].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | wc -l)
19+
count=$(jq -c '.[].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | wc -l)
2020
if [[ "$count" != "0" ]] ; then
2121
echo "Synchronizing existing redis databases"
22-
jq -c '.[0].objects | .[] | .object' ${BINDING_CONTEXT_PATH} | tr '\n' '\0' | xargs -0 /engine/add.sh
22+
while IFS= read -r object; do
23+
/engine/add.sh "$object"
24+
done< <(jq -c '.[].objects | .[] | .object' < ${BINDING_CONTEXT_PATH})
2325
fi
2426
fi
2527
fi

0 commit comments

Comments
 (0)