Fix macOS compatibility: Add portable timeout helper

- Add utils.sh with cross-platform timeout functions for macOS compatibility
- Fix sf-logs-tail to use portable_timeout instead of GNU timeout command
- Fix test-all-wrappers.sh to use portable_timeout_seconds for testing
- Update README.md with macOS compatibility documentation

The timeout command is not available by default on macOS, causing
sf-logs-tail and test scripts to fail. The new utils.sh provides
fallback timeout functionality that works on Linux, macOS with/without
GNU coreutils, maintaining exit code 124 compatibility.
This commit is contained in:
reynold
2025-08-28 21:08:58 +08:00
parent 159ede3794
commit ca98742891
4 changed files with 125 additions and 2 deletions

View File

@@ -3,6 +3,9 @@
# Debug logs tail wrapper for Salesforce CLI
# Provides real-time debug log monitoring with filtering and formatting
# Source utilities for cross-platform compatibility
source "$(dirname "$0")/utils.sh"
# Color codes for output formatting
readonly RED='\033[0;31m'
readonly GREEN='\033[0;32m'
@@ -291,7 +294,7 @@ if [[ "$VERBOSE" == true ]]; then
fi
# Start the log tailing with timeout
timeout "${DURATION}m" sf "${SF_ARGS[@]}" 2>/dev/null | while IFS= read -r line; do
portable_timeout "$DURATION" sf "${SF_ARGS[@]}" 2>/dev/null | while IFS= read -r line; do
if should_show_log_entry "$line" "$FILTER_PATTERN" "$APEX_ONLY"; then
format_log_entry "$line" "$SHOW_COLORS" "$VERBOSE"
fi