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nB;AACD,KAFD,MAGK;AACH,MAAA,CAAC,CAAC,QAAD,CAAD,GAAgB,KAAhB;AACD;AACF;;AAED,EAAA,IAAI,CAAC,IAAD,EAAa;AACf;AACA,QAAI,KAAK,SAAL,IAAkB,MAAM,CAAC,IAAP,CAAY,KAAK,IAAjB,EAAuB,MAAvB,GAAgC,CAAtD,EAAyD;AACvD,aAAO,2BAAW,IAAX,EAAiB,6BAAgB,KAAK,IAArB,CAAjB,CAAP;AACD,KAFD,MAGK;AACH,aAAO,OAAO,CAAC,OAAR,EAAP;AACD;AACF;;AA9CqB,C","sourcesContent":["import { outputFile } from \"fs-extra\"\nimport { serializeToYaml } from \"./util\"\n\nexport class DebugLogger {\n readonly data: any = {}\n\n constructor(readonly isEnabled = true) {\n }\n\n add(key: string, value: any) {\n if (!this.isEnabled) {\n return\n }\n\n const dataPath = key.split(\".\")\n let o = this.data\n let lastName: string | null = null\n for (const p of dataPath) {\n if (p === dataPath[dataPath.length - 1]) {\n lastName = p\n break\n }\n else {\n if (o[p] == null) {\n o[p] = Object.create(null)\n }\n else if (typeof o[p] === \"string\") {\n o[p] = [o[p]]\n }\n o = o[p]\n }\n }\n\n if (Array.isArray(o[lastName!!])) {\n o[lastName!!].push(value)\n }\n else {\n o[lastName!!] = value\n }\n }\n\n save(file: string) {\n // toml and json doesn't correctly output multiline string as multiline\n if (this.isEnabled && Object.keys(this.data).length > 0) {\n return outputFile(file, serializeToYaml(this.data))\n }\n else {\n return Promise.resolve()\n }\n }\n}"],"sourceRoot":""}
|