UNPKG

pg-proto-parser

Version:
29 lines (28 loc) 903 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PgProtoParser = void 0; const protobufjs_1 = require("@launchql/protobufjs"); const fs_1 = require("fs"); const store_1 = require("./store"); const options_1 = require("./options"); class PgProtoParser { inFile; options; constructor(inFile, options) { this.inFile = inFile; this.options = (0, options_1.getOptionsWithDefaults)(options); } readProtoFile() { return (0, fs_1.readFileSync)(this.inFile, 'utf-8'); } parseProto(content) { return (0, protobufjs_1.parse)(content, this.options.parser); } write() { const protoContent = this.readProtoFile(); const ast = this.parseProto(protoContent); const store = new store_1.ProtoStore(ast.root, this.options); store.write(); } } exports.PgProtoParser = PgProtoParser;