#!/usr/bin/env bash
#
# mx hook: pre-work-unarchive
#
# Runs BEFORE `mx work unarchive` re-creates the worktrees (none on disk yet).
# A non-zero exit ABORTS the unarchive (HOOK_FAILED).
#
# This is a shared, runtime-wide hook — it fires for EVERY repo/work, so branch
# on the context below. Write it in any language: just set the shebang and keep
# the file executable (e.g. #!/usr/bin/env node or #!/usr/bin/env python3).
#
# Working directory: the work folder.
# Context (environment variables):
#     $MX_WORK — work name
#     $MX_WORK_PATH — absolute work folder
#     $MX_EVENT (this event name), $MX_RUNTIME (runtime root)
#
# No-op by default — delete this file to disable the hook entirely.
set -euo pipefail

# Branch on the context to do per-repo / per-work / per-branch logic, e.g.:
#   case "${MX_REPO:-}" in
#     web)  npm --prefix "$MX_WORKTREE_PATH" install ;;
#     api)  cp "$MX_RUNTIME/secrets/api.env" "$MX_WORKTREE_PATH/.env" ;;
#   esac

exit 0
