20 lines
663 B
Bash
Executable File
20 lines
663 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
state_dir="${COPILOT_RESOURCES_STATE_DIR:-$HOME/.copilot-resources-state}"
|
|
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
port_registry_script="$script_dir/update-port-registry.mjs"
|
|
mkdir -p -- "$state_dir"
|
|
|
|
event_payload="$(cat)"
|
|
printf '%s\n' "$event_payload" >> "$state_dir/hook-events.log"
|
|
|
|
if command -v node >/dev/null 2>&1 && [[ -f "$port_registry_script" ]]; then
|
|
if ! printf '%s' "$event_payload" | node "$port_registry_script"; then
|
|
printf '%s update-port-registry failed\n' "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$state_dir/project-ports-errors.log"
|
|
fi
|
|
fi
|
|
|
|
printf '{"continue": true}\n'
|