#!/usr/bin/env bash # Removes this branch's Xcode derived data — the folder # `scripts/lib/derived-data.sh` names — after a shipping lane has archived. # # scripts/ci/remove-derived-data.sh # # WHY A SCRIPT AND NOT `rm -rf "$(…)"` IN THE WORKFLOW. `COTTON_DERIVED_DATA` # is printed as given, so a workflow that removed whatever came back would # remove a home folder the day the variable named one. This asks # `scripts/lib/owned-root.sh` first and exits 2, removing nothing, when the # folder is a home folder or anything above one. # # Guard: the owned-root test. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=/dev/null . "$HERE/../lib/derived-data.sh" # shellcheck source=/dev/null . "$HERE/../lib/owned-root.sh" dir="$(cotton_derived_data)" refuse_wide_root "the derived data folder (COTTON_DERIVED_DATA / COTTON_DERIVED_ROOT)" "$dir" rm -rf "$dir"