summaryrefslogtreecommitdiff
path: root/packages/core/src/services/fileSystemService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/services/fileSystemService.ts')
-rw-r--r--packages/core/src/services/fileSystemService.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/core/src/services/fileSystemService.ts b/packages/core/src/services/fileSystemService.ts
index e2f30cf4..3e4cd30f 100644
--- a/packages/core/src/services/fileSystemService.ts
+++ b/packages/core/src/services/fileSystemService.ts
@@ -5,6 +5,7 @@
*/
import fs from 'fs/promises';
+import protobuf from 'protobufjs';
/**
* Interface for file system operations that may be delegated to different implementations
@@ -19,6 +20,14 @@ export interface FileSystemService {
readTextFile(filePath: string): Promise<string>;
/**
+ * Read and parse a proto file
+ *
+ * @param filePath - The path to the file to read
+ * @returns The file content as a JSON string
+ */
+ readProtoFile(filePath: string): Promise<string>;
+
+ /**
* Write text content to a file
*
* @param filePath - The path to the file to write
@@ -35,6 +44,11 @@ export class StandardFileSystemService implements FileSystemService {
return fs.readFile(filePath, 'utf-8');
}
+ async readProtoFile(filePath: string): Promise<string> {
+ const root = await protobuf.load(filePath);
+ return JSON.stringify(root.toJSON(), null, 2);
+ }
+
async writeTextFile(filePath: string, content: string): Promise<void> {
await fs.writeFile(filePath, content, 'utf-8');
}