(workspaceId: string)
| 121 | } |
| 122 | |
| 123 | private async readFile(workspaceId: string): Promise<SessionUsageFile> { |
| 124 | try { |
| 125 | const data = await fs.readFile(this.getFilePath(workspaceId), "utf-8"); |
| 126 | return JSON.parse(data) as SessionUsageFile; |
| 127 | } catch (error) { |
| 128 | if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") { |
| 129 | return this.createEmptyUsageFile(); |
| 130 | } |
| 131 | throw error; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | private async writeFile(workspaceId: string, data: SessionUsageFile): Promise<void> { |
| 136 | const filePath = this.getFilePath(workspaceId); |
no test coverage detected