From c711ce4abaa7ffb79b503d7f524e570da9cd03a9 Mon Sep 17 00:00:00 2001 From: yuetloo Date: Mon, 22 Jan 2024 22:27:13 -0500 Subject: [PATCH] ignore file not found error when updating the file --- contracts/utils/JSONFile.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contracts/utils/JSONFile.ts b/contracts/utils/JSONFile.ts index 384bd3d01..e87194284 100644 --- a/contracts/utils/JSONFile.ts +++ b/contracts/utils/JSONFile.ts @@ -34,7 +34,12 @@ export class JSONFile { * @param data The new data to add to the JSON content */ static update(path: string, data: any) { - const state = JSONFile.read(path) + let state: any + try { + state = JSONFile.read(path) + } catch { + state = {} + } fs.writeFileSync(path, JSON.stringify({ ...state, ...data }, null, 2)) }