From a63f534979a2fdaba7f4111be3aad9348a69e4c5 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 30 Apr 2018 13:31:12 -0700 Subject: [PATCH] Change 'include' to 'includeDirs' in proto-loader package --- packages/grpc-protobufjs/README.md | 2 +- packages/grpc-protobufjs/src/index.ts | 18 +++++++++--------- test/interop/interop_client.js | 2 +- test/interop/interop_server.js | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/grpc-protobufjs/README.md b/packages/grpc-protobufjs/README.md index 4e57faf4c..307c635c1 100644 --- a/packages/grpc-protobufjs/README.md +++ b/packages/grpc-protobufjs/README.md @@ -36,7 +36,7 @@ The options parameter is an object that can have the following optional properti | `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`. | `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`. | `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`. -| `include` | An array of strings | A list of search paths for imported `.proto` files. +| `includeDirs` | An array of strings | A list of search paths for imported `.proto` files. The following options object closely approximates the existing behavior of `grpc.load`: diff --git a/packages/grpc-protobufjs/src/index.ts b/packages/grpc-protobufjs/src/index.ts index 85c2c9413..5f443f983 100644 --- a/packages/grpc-protobufjs/src/index.ts +++ b/packages/grpc-protobufjs/src/index.ts @@ -48,7 +48,7 @@ export interface PackageDefinition { } export type Options = Protobuf.IParseOptions & Protobuf.IConversionOptions & { - include?: string[]; + includeDirs?: string[]; }; function joinName(baseName: string, name: string): string { @@ -154,15 +154,15 @@ function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) { * `defaults` is `false`. Defaults to `false`. * @param options.oneofs Set virtual oneof properties to the present field's * name - * @param options.include Paths to search for imported `.proto` files. + * @param options.includeDirs Paths to search for imported `.proto` files. */ export function load(filename: string, options: Options): Promise { const root: Protobuf.Root = new Protobuf.Root(); - if (!!options.include) { - if (!(options.include instanceof Array)) { - return Promise.reject(new Error('The include option must be an array')); + if (!!options.includeDirs) { + if (!(options.includeDirs instanceof Array)) { + return Promise.reject(new Error('The includeDirs option must be an array')); } - addIncludePathResolver(root, options.include as string[]); + addIncludePathResolver(root, options.includeDirs as string[]); } return root.load(filename, options).then((loadedRoot) => { loadedRoot.resolveAll(); @@ -172,11 +172,11 @@ export function load(filename: string, options: Options): Promise