diff --git a/tools/pbtools/app.js b/tools/pbtools/app.js index 18e157e4..81ef878c 100644 --- a/tools/pbtools/app.js +++ b/tools/pbtools/app.js @@ -14,7 +14,11 @@ class PBTools { this.protoDir = './proto/'; } - async init() { + async loadCsPb() { + if (!fs.existsSync(this.protoDir + 'cs_proto.proto')) { + console.error('cs_proto.proto file not exists'); + return; + } { this.csProtoPb = await (new protobuf.Root()).load( this.protoDir + 'cs_proto.proto', @@ -33,6 +37,13 @@ class PBTools { this.csCmMsgId = this.csMsgIdPb.lookup('CMMessageId_e'); this.csSmMsgId = this.csMsgIdPb.lookup('SMMessageId_e'); } + } + + async loadSsPb() { + if (!fs.existsSync(this.protoDir + 'ss_proto.proto')) { + console.error('ss_proto.proto file not exists'); + return; + } { this.ssProtoPb = await (new protobuf.Root()).load( this.protoDir + 'ss_proto.proto', @@ -50,6 +61,13 @@ class PBTools { ); this.ssSSmMsgId = this.ssMsgIdPb.lookup('SSMMessageId_e'); } + } + + async loadMtPb() { + if (!fs.existsSync(this.protoDir + 'mt.proto')) { + console.error('mt.proto file not exists'); + return; + } { this.mtPb = await (new protobuf.Root()).load( this.protoDir + 'mt.proto', @@ -58,9 +76,18 @@ class PBTools { } ); } - await this.genCsAutoGen(); - await this.genMtbAutoGen(); - await this.genSsAutoGen(); + } + + async init() { + if (this.csProtoPb) { + await this.genCsAutoGen(); + } + if (this.ssProtoPb) { + await this.genMtbAutoGen(); + } + if (this.mtPb) { + await this.genSsAutoGen(); + } } async genCsAutoGen() {