From 867d094e6ce32f418a2ce512814f67f3ecb9d969 Mon Sep 17 00:00:00 2001 From: Derek Brans Date: Tue, 14 Jan 2025 21:48:34 -0500 Subject: [PATCH] detect missing circular-deps.json --- development/circular-deps.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/development/circular-deps.sh b/development/circular-deps.sh index 700d673704d3..f3bb792695bd 100755 --- a/development/circular-deps.sh +++ b/development/circular-deps.sh @@ -10,6 +10,13 @@ if [[ "$COMMAND" != "check" && "$COMMAND" != "update" ]]; then exit 1 fi +# Print instructions for how to resolve circular dependency issues +print_resolution_steps() { + echo "You can resolve this by either:" + echo "1. Add comment '@metamaskbot update-circular-deps' on this PR" + echo "2. Run 'yarn circular-deps:update' locally and commit the changes." +} + # Normalizes JSON output by sorting both the individual cycles and the array of cycles. # This ensures consistent output regardless of cycle starting point. # @@ -35,18 +42,22 @@ madge_json() { } if [[ "$COMMAND" == "check" ]]; then + # Check if circular-deps.json exists + if [ ! -f circular-deps.json ]; then + echo "Error: circular-deps.json does not exist." + print_resolution_steps + exit 1 + fi + # Generate current circular dependencies madge_json > circular-deps.temp.json || true - # Compare files silently DIFF_OUTPUT=$(diff circular-deps.json circular-deps.temp.json || true) if [ -n "$DIFF_OUTPUT" ]; then echo "Error: Codebase circular dependencies are out of sync in circular-deps.json" - echo "You can resolve this by either:" - echo "1. Add comment '@metamaskbot update-circular-deps' on this PR" - echo "2. Run 'yarn circular-deps:update' locally and commit the changes." + print_resolution_steps rm circular-deps.temp.json exit 1 fi