From 7b61a11a179468542c87c2ecc36f1f50880591f7 Mon Sep 17 00:00:00 2001 From: Joone Hur Date: Mon, 18 Mar 2024 01:34:20 -0700 Subject: [PATCH] Update attribution handling in Loz constructor Refactor attribution handling in the Loz constructor to ensure proper configuration and error handling. Fix potential bugs and improve code readability. Generated by gpt-3.5-turbo --- src/loz.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/loz.ts b/src/loz.ts index 82f3fd0..efb1c76 100644 --- a/src/loz.ts +++ b/src/loz.ts @@ -62,16 +62,20 @@ export class Loz { fs.mkdirSync(LOG_DEV_PATH); } - const attributionValue = await this.git.configLoz("attribution"); - if (attributionValue === "") { - this.git.configLoz("attribution", "false"); - this.attribution = false; - } else { - if (attributionValue.trimEnd() === "true") { - this.attribution = true; - } else { + try { + const attributionValue = await this.git.configLoz("attribution"); + if (attributionValue === "") { + this.git.configLoz("attribution", "false"); this.attribution = false; + } else { + if (attributionValue.trimEnd() === "true") { + this.attribution = true; + } else { + this.attribution = false; + } } + } catch (error: any) { + if (DEBUG) console.log("Error reading git config: " + error); } }