Skip to content

Commit f14207f

Browse files
fallintoplacemeta-codesync[bot]
authored andcommitted
Fix codegen script phase error logging (#56956)
Summary: This fixes the `error()` helper in `packages/react-native/scripts/react_native_pods_utils/script_phases.sh` so it logs messages instead of attempting to execute them as shell commands. The current implementation does: ```bash "[Codegen] $1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1 ``` That causes the error path to fail with `command not found` under `set -e`, writes the shell error to `SCRIPT_OUTPUT_FILE_0` instead of the intended `[Codegen] ...` line, and truncates multi-part messages to `$1`. This change captures the full message with `$*`, prints it to stdout, and appends the formatted `[Codegen] ...` line to `SCRIPT_OUTPUT_FILE_0`. Fixes #56955. ## Changelog: [IOS] [FIXED] - Fix codegen script phase error logging in `script_phases.sh` Pull Request resolved: #56956 Test Plan: ```bash bash -n packages/react-native/scripts/react_native_pods_utils/script_phases.sh ``` ```bash bash -lc 'set +e; bash -lc '\''set -e; rm -f /tmp/rn-codegen-test.log; f(){ message="$*"; echo "$message"; echo "[Codegen] $message" >> /tmp/rn-codegen-test.log 2>&1; exit 1; }; f hello world'\''; status=$?; echo STATUS=$status; echo LOG_CONTENT_START; cat /tmp/rn-codegen-test.log 2>/dev/null; echo LOG_CONTENT_END' ``` Observed output: ```text hello world STATUS=1 LOG_CONTENT_START [Codegen] hello world LOG_CONTENT_END ``` Reviewed By: christophpurrer Differential Revision: D106401068 Pulled By: zeyap fbshipit-source-id: 1ca73c20d5b935f3451e4c48da171b6f6c22201f
1 parent d4ae881 commit f14207f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/react-native/scripts/react_native_pods_utils/script_phases.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ cd "$RCT_SCRIPT_RN_DIR"
1616
CODEGEN_CLI_PATH=""
1717

1818
error () {
19-
echo "$1"
20-
"[Codegen] $1" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
19+
message="$*"
20+
echo "$message"
21+
echo "[Codegen] $message" >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1
2122
exit 1
2223
}
2324

0 commit comments

Comments
 (0)