diff options
| author | Castor Regex <[email protected]> | 2025-10-22 05:31:24 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-22 05:31:24 -0500 |
| commit | a0c590944ff82d3584a532cd7400689297735757 (patch) | |
| tree | 60ba1506f7ea2ec2aaa630e2ab4abfa16681f950 /packages/core/src/services/fileSystemService.ts | |
| parent | 1799aac8ae4355bf912238c650856e82da641f6d (diff) | |
feat: add support for .proto files
Diffstat (limited to 'packages/core/src/services/fileSystemService.ts')
| -rw-r--r-- | packages/core/src/services/fileSystemService.ts | 14 |
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'); } |
