testsAndMisc/meta/scripts/run_prettier_capped.sh
Krzysztof kuhy Rudnicki db6276b3ff refactor(linux_configuration): move remaining dirs + scripts/ to meta/
- Move fresh-install/ → scripts/single_use/fresh-install/
- Move hosts/ → scripts/periodic_background/hosts/
- Move i3-configuration/ → scripts/periodic_background/i3-configuration/
- Delete linux_configuration/LaTeX/, nix-poc/, report/ (dead dirs)
- Move repo-root scripts/ → meta/scripts/
- Update root .pre-commit-config.yaml: scripts/ → meta/scripts/ (9 entries)
- Update run.sh ARTIFACT_INIT_SCRIPT to meta/scripts/
- Update fresh-install/main.sh: hosts/install.sh + i3-configuration/install.sh paths
- Update check_python_location.sh: add meta/scripts/ to exception list
- Fix midnight flakiness in test_recent_workout_returns_true: use timezone-aware
  local noon instead of now-1h to avoid SQL date() boundary issues
2026-05-15 00:53:01 +02:00

27 lines
894 B
Bash
Executable File

#!/usr/bin/env bash
# Run prettier --check inside its own systemd-run scope so its memory
# budget is independent of the outer pre-push cgroup (which has already
# accumulated page-cache footprint from pytest/mypy/pylint/bandit).
#
# Falls back to a direct invocation when systemd-run is unavailable
# (CI / containers without systemd user instance).
set -euo pipefail
if [ $# -eq 0 ]; then
exit 0
fi
# Cap Node heap on top of the cgroup limit for belt-and-braces safety.
export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=768"
if command -v systemd-run >/dev/null 2>&1 \
&& systemctl --user is-active --quiet default.target 2>/dev/null \
|| command -v systemd-run >/dev/null 2>&1; then
exec systemd-run --user --scope --quiet --collect \
-p MemoryMax=1G \
-p MemorySwapMax=0 \
-- prettier --check "$@"
fi
exec prettier --check "$@"