From e0b7fe8dffd7f6522188a74864e18f183bb5c844 Mon Sep 17 00:00:00 2001 From: Zack Winter <3457246+zackwintermdb@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:32:16 -0700 Subject: [PATCH] SERVER-92234 Explicitly exempt formatting anything in build output dirs (#24481) GitOrigin-RevId: 2c817e7cc42d1d8500c0e3ec147bf6ca00cd76e1 --- .prettierignore | 4 ++++ bazel/format/format.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 3736a388fcb..c594a7c06cf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -30,3 +30,7 @@ version_expansions.yml # Ignore all formatting in third_party/* src/third_party + +# Ignore anything in the build output directories +build +bazel-* diff --git a/bazel/format/format.py b/bazel/format/format.py index 396d3f0b3a5..4226ac7b09f 100644 --- a/bazel/format/format.py +++ b/bazel/format/format.py @@ -5,8 +5,12 @@ import subprocess def run_prettier(prettier: pathlib.Path, check: bool) -> int: + # Explicitly ignore anything in the output directories to prevent bad symlinks from failing the run, + # see https://github.com/prettier/prettier/issues/11568 as to why it the paths being present in + # .prettierignore isn't sufficient + force_exclude_dirs = ["!./build", "!./bazel-bin", "!./bazel-out", "!./bazel-mongo"] try: - command = [prettier, "."] + command = [prettier, "."] + force_exclude_dirs if check: command.append("--check") else: