Skip to content

Commit 24ca072

Browse files
fix: handle null delimited filenames
1 parent 940de10 commit 24ca072

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/scripts/process-passport-tutorials.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ mkdir -p "$TUTORIALS_DIR"
2525
# Find all tutorial.md files
2626
TUTORIAL_FILES=$(find "$PASSPORT_ROOT" -name "tutorial.md" -type f)
2727

28-
for TUTORIAL_FILE in $TUTORIAL_FILES; do
28+
# Process null-delimited filenames
29+
find "$PASSPORT_ROOT" -name "tutorial.md" -type f -print0 | while IFS= read -r -d '' TUTORIAL_FILE; do
2930
echo "Processing $TUTORIAL_FILE"
3031

3132
# Extract feature directory
3233
FEATURE_DIR=$(dirname "$TUTORIAL_FILE")
3334

3435
# Try to find script file in this directory
35-
SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f | head -n 1)
36+
SCRIPT_FILE=$(find "$FEATURE_DIR" -name "*.cs" -type f -print0 | xargs -0 -n1 echo | head -n 1)
3637
if [ -z "$SCRIPT_FILE" ]; then
3738
echo "Warning: No script file found in $FEATURE_DIR, using directory name"
3839
FEATURE_NAME=$(basename "$FEATURE_DIR")
@@ -41,7 +42,11 @@ for TUTORIAL_FILE in $TUTORIAL_FILES; do
4142
SCRIPT_FILENAME=$(basename "$SCRIPT_FILE")
4243

4344
# Look up the feature name in features.json
44-
FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON")
45+
# Extract feature name with error handling
46+
if ! FEATURE_NAME=$(jq -r ".features[] | to_entries[] | select(.value == \"$SCRIPT_FILENAME\") | .key" "$FEATURES_JSON" 2>/dev/null); then
47+
echo "Warning: Error parsing features.json with jq, using directory name"
48+
FEATURE_NAME=$(basename "$FEATURE_DIR")
49+
fi
4550

4651
# If not found in features.json, fallback to directory name
4752
if [ -z "$FEATURE_NAME" ] || [ "$FEATURE_NAME" == "null" ]; then

0 commit comments

Comments
 (0)