Skip to content

Commit 1d8e16e

Browse files
committed
Trying something
1 parent 5aa5f66 commit 1d8e16e

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

scripts/fetch-repos.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,9 @@ fetch_repos() {
2424
while true; do
2525
RESPONSE=$(fetch_repos)
2626

27-
# Debug: Output the raw response
28-
echo "Response: $RESPONSE" >> debug.log
29-
3027
# Parse the JSON response to extract repository names
3128
REPO_NAMES=$(echo "$RESPONSE" | jq -r '.[] | select(.name != ".github") | .name')
3229

33-
# Debug: Output the extracted repository names
34-
echo "Repository Names: $REPO_NAMES" >> debug.log
35-
3630
# Check if no more repositories were returned
3731
if [ -z "$REPO_NAMES" ]; then
3832
break
@@ -46,9 +40,6 @@ while true; do
4640
# Check if the .jsonld file exists in the annotations repository
4741
FILE_EXISTS=$(curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/repos/$ANNOTATIONS_REPO/contents/${JSONLD_FILE}" | jq -r '.name // empty')
4842

49-
# Debug: Output the result of the file existence check
50-
echo "Checking $JSONLD_FILE: $FILE_EXISTS" >> debug.log
51-
5243
if [ -n "$FILE_EXISTS" ]; then
5344
ANNOTATED=true
5445
fi
@@ -61,9 +52,14 @@ while true; do
6152
((PAGE++))
6253
done
6354

64-
# Write repository information to the JSON file, ensuring it's clean
65-
echo "[${REPOS[*]}]" | jq '.' > "$OUTPUT_FILE"
55+
# Refactor JSON output handling
56+
if [ ${#REPOS[@]} -eq 0 ]; then
57+
# If no repositories were found, write an empty array
58+
echo "[]" > "$OUTPUT_FILE"
59+
else
60+
# Join the REPOS array into a single JSON array
61+
JSON_ARRAY=$(printf "%s," "${REPOS[@]}" | sed 's/,$//') # Remove trailing comma
62+
echo "[$JSON_ARRAY]" | jq '.' > "$OUTPUT_FILE"
63+
fi
6664

67-
# Debug: Output final JSON file content
68-
cat "$OUTPUT_FILE" >> debug.log
6965
echo "Repository information has been fetched and saved to $OUTPUT_FILE"

src/assets/repos.json

Whitespace-only changes.

0 commit comments

Comments
 (0)