[Chapel Merge] Prevent chpl-shim from overwriting files when unnecessary

Branch: refs/heads/main
Revision: 1373833c04abab0cb7040f7bd3c42c3b5697d20f
Author: jabraham17
Link: Prevent chpl-shim from overwriting files when unnecessary by jabraham17 · Pull Request #25227 · chapel-lang/chapel · GitHub
Log Message:
Prevent chpl-shim from overwriting files when unnecessary (#25227)

Prevents chpl-shim from overwriting files when there is nothing to do.
This can cause issues with chpl-shim mason build where mason doesn't
rebuild without source modification. This results in chpl-shim writing
an empty .cls-commands.json file.

Resolves [Bug]: `chpl-shim` produces empty json if run twice on mason · Issue #25226 · chapel-lang/chapel · GitHub

Tested that multiple chpl-shim mason build runs do not break
.cls-commands.json

[Reviewed by @DanilaFe]

Compare: Comparing a1cde47a90b7b18a4b0d409e3a0a9dfadbe13111...84d093163e30fe68278a0190263d1a0a09bfe5e0 · chapel-lang/chapel · GitHub

Diff:
M tools/chpl-language-server/src/chpl-shim.py
https://github.com/chapel-lang/chapel/pull/25227.diff