fix: handle missing date in no-node fallback path

Use command -v guard and fallback to "unknown" timestamp when
neither node nor date is available. Suppresses stderr and ensures
valid JSON output in all minimal environments.
This commit is contained in:
Joey Krug
2026-02-13 06:15:40 +00:00
committed by Gustavo Madeira Santana
parent 3e8baf1e88
commit 1c18f08cc6

View File

@@ -30,7 +30,10 @@ if [ "$#" -gt 0 ]; then
fi
if ! command -v node &>/dev/null; then
echo '{"error":"node not found on PATH","orphaned":[],"ts":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"}'
_ts="unknown"
command -v date &>/dev/null && _ts="$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null)" || true
[ -z "$_ts" ] && _ts="unknown"
printf '{"error":"node not found on PATH","orphaned":[],"ts":"%s"}\n' "$_ts"
exit 0
fi