This repository was archived by the owner on Nov 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -198,20 +198,21 @@ export class GrpcClient {
198198 * @return {Object<string, *> } The gRPC loaded result (the toplevel namespace
199199 * object).
200200 */
201+
201202 loadProto ( protoPath : string , filename : string ) {
202- // This set of @grpc /proto-loader options
203- // 'closely approximates the existing behavior of grpc.load'
204- const includeDirs = INCLUDE_DIRS . slice ( ) ;
205- includeDirs . unshift ( protoPath ) ;
206- const options = {
207- keepCase : true ,
208- longs : String ,
209- enums : String ,
210- defaults : true ,
211- oneofs : true ,
212- includeDirs
213- } ;
214- return this . loadFromProto ( filename , options ) ;
203+ const resolvedPath = GrpcClient . _resolveFile ( protoPath , filename ) ;
204+ const retval = this . grpc . loadObject (
205+ protobuf . loadSync ( resolvedPath , new GoogleProtoFilesRoot ( ) ) ) ;
206+ return retval ;
207+ }
208+
209+ static _resolveFile ( protoPath : string , filename : string ) {
210+ if ( fs . existsSync ( path . join ( protoPath , filename ) ) ) {
211+ return path . join ( protoPath , filename ) ;
212+ } else if ( COMMON_PROTO_FILES . indexOf ( filename ) > - 1 ) {
213+ return path . join ( googleProtoFilesDir , filename ) ;
214+ }
215+ throw new Error ( filename + ' could not be found in ' + protoPath ) ;
215216 }
216217
217218 metadataBuilder ( headers : OutgoingHttpHeaders ) {
You can’t perform that action at this time.
0 commit comments