From e5658bc05acc768fac1723c8d455f20910237f0a Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Thu, 30 May 2024 13:02:36 -0700 Subject: [PATCH] Remove compile_commands.json before writing it This fix existing as a symlink to a cmake directory seems like a pretty common use case, and the error when it fails to write is pretty inscrutable. Fixes https://github.com/hedronvision/bazel-compile-commands-extractor/issues/105 --- refresh.template.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/refresh.template.py b/refresh.template.py index 3b33701..3b43db4 100644 --- a/refresh.template.py +++ b/refresh.template.py @@ -1414,6 +1414,11 @@ def main(): There should be actionable warnings, above, that led to this.""") sys.exit(1) + try: + os.remove('compile_commands.json') + except FileNotFoundError: + pass + # Chain output into compile_commands.json with open('compile_commands.json', 'w') as output_file: json.dump(