#!/usr/bin/env bash
set -euo pipefail
task_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
task_working_dir="$(pwd -P)"
case "$task_working_dir" in
  "$task_root"/build/*/ios)
    if [[ "${1:-}" == install ]]; then
      # Both clean and previously prepared app targets use the reviewed lock.
      # Otherwise a generated 6.2.1 lock survives the IQKeyboardManager pin fix.
      if ! cmp -s "$task_root/scripts/ios/Podfile.lock" Podfile.lock; then
        cp "$task_root/scripts/ios/Podfile.lock" Podfile.lock
      fi
    fi
    ;;
esac
exec bundle exec pod "$@"
