Skip to content

Commit 1b9b989

Browse files
authored
Merge pull request #298 from murgatroid99/proto_loader_include_option_name_change
Change 'include' to 'includeDirs' in proto-loader package
2 parents c9aa5f7 + a63f534 commit 1b9b989

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

packages/grpc-protobufjs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The options parameter is an object that can have the following optional properti
3636
| `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`.
3737
| `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`.
3838
| `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`.
39-
| `include` | An array of strings | A list of search paths for imported `.proto` files.
39+
| `includeDirs` | An array of strings | A list of search paths for imported `.proto` files.
4040

4141
The following options object closely approximates the existing behavior of `grpc.load`:
4242

packages/grpc-protobufjs/src/index.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface PackageDefinition {
4848
}
4949

5050
export type Options = Protobuf.IParseOptions & Protobuf.IConversionOptions & {
51-
include?: string[];
51+
includeDirs?: string[];
5252
};
5353

5454
function joinName(baseName: string, name: string): string {
@@ -154,15 +154,15 @@ function addIncludePathResolver(root: Protobuf.Root, includePaths: string[]) {
154154
* `defaults` is `false`. Defaults to `false`.
155155
* @param options.oneofs Set virtual oneof properties to the present field's
156156
* name
157-
* @param options.include Paths to search for imported `.proto` files.
157+
* @param options.includeDirs Paths to search for imported `.proto` files.
158158
*/
159159
export function load(filename: string, options: Options): Promise<PackageDefinition> {
160160
const root: Protobuf.Root = new Protobuf.Root();
161-
if (!!options.include) {
162-
if (!(options.include instanceof Array)) {
163-
return Promise.reject(new Error('The include option must be an array'));
161+
if (!!options.includeDirs) {
162+
if (!(options.includeDirs instanceof Array)) {
163+
return Promise.reject(new Error('The includeDirs option must be an array'));
164164
}
165-
addIncludePathResolver(root, options.include as string[]);
165+
addIncludePathResolver(root, options.includeDirs as string[]);
166166
}
167167
return root.load(filename, options).then((loadedRoot) => {
168168
loadedRoot.resolveAll();
@@ -172,11 +172,11 @@ export function load(filename: string, options: Options): Promise<PackageDefinit
172172

173173
export function loadSync(filename: string, options: Options): PackageDefinition {
174174
const root: Protobuf.Root = new Protobuf.Root();
175-
if (!!options.include) {
176-
if (!(options.include instanceof Array)) {
175+
if (!!options.includeDirs) {
176+
if (!(options.includeDirs instanceof Array)) {
177177
throw new Error('The include option must be an array');
178178
}
179-
addIncludePathResolver(root, options.include as string[]);
179+
addIncludePathResolver(root, options.includeDirs as string[]);
180180
}
181181
const loadedRoot = root.loadSync(filename, options);
182182
loadedRoot.resolveAll();

test/interop/interop_client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var protoPackage = protoLoader.loadSync(
2929
{keepCase: true,
3030
defaults: true,
3131
enums: String,
32-
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
32+
includeDirs: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
3333
var testProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;
3434

3535
var assert = require('assert');

test/interop/interop_server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var protoPackage = protoLoader.loadSync(
3030
{keepCase: true,
3131
defaults: true,
3232
enums: String,
33-
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
33+
includeDirs: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
3434
var testProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;
3535

3636
var ECHO_INITIAL_KEY = 'x-grpc-test-echo-initial';

0 commit comments

Comments
 (0)