Skip to content

Commit

Permalink
fix: ensure that frontend configuration does not error if correct dat…
Browse files Browse the repository at this point in the history
…a already written out
  • Loading branch information
philtweir committed Oct 4, 2024
1 parent cc16842 commit 71012e0
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions arches/settings_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,19 @@ def generate_frontend_configuration():
f"Writing frontend configuration to: {frontend_configuration_settings_path} \n"
)

with open(
frontend_configuration_settings_path,
"w",
) as file:
json.dump(frontend_configuration_settings_data, file, indent=4)
try:
with open(
frontend_configuration_settings_path,
"r",
) as file:
if json.load(file) != frontend_configuration_settings_data:
raise RuntimeError("App frontend configuration exists but does not match")
except IOError:
with open(
frontend_configuration_settings_path,
"w",
) as file:
json.dump(frontend_configuration_settings_data, file, indent=4)

tsconfig_paths_data = {
"_comment": "This is a generated file. Do not edit directly.",
Expand Down Expand Up @@ -214,8 +222,14 @@ def generate_frontend_configuration():
)
sys.stdout.write(f"Writing tsconfig path data to: {tsconfig_path} \n")

with open(tsconfig_path, "w") as file:
json.dump(tsconfig_paths_data, file, indent=4)
try:
with open(tsconfig_path, "r") as file:
if json.load(file) != tsconfig_paths_data:
raise RuntimeError("App frontend configuration exists but does not match")
except IOError:
with open(tsconfig_path, "w") as file:
json.dump(tsconfig_paths_data, file, indent=4)


except Exception as e:
# Ensures error message is shown if error encountered
Expand Down

0 comments on commit 71012e0

Please sign in to comment.