mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Change 'include' to 'includeDirs' in proto-loader package
This commit is contained in:
parent
f1acaf299a
commit
a63f534979
@ -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`:
|
||||
|
||||
|
||||
@ -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<PackageDefinition> {
|
||||
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<PackageDefinit
|
||||
|
||||
export function loadSync(filename: string, options: Options): PackageDefinition {
|
||||
const root: Protobuf.Root = new Protobuf.Root();
|
||||
if (!!options.include) {
|
||||
if (!(options.include instanceof Array)) {
|
||||
if (!!options.includeDirs) {
|
||||
if (!(options.includeDirs instanceof Array)) {
|
||||
throw new Error('The include option must be an array');
|
||||
}
|
||||
addIncludePathResolver(root, options.include as string[]);
|
||||
addIncludePathResolver(root, options.includeDirs as string[]);
|
||||
}
|
||||
const loadedRoot = root.loadSync(filename, options);
|
||||
loadedRoot.resolveAll();
|
||||
|
||||
@ -29,7 +29,7 @@ var protoPackage = protoLoader.loadSync(
|
||||
{keepCase: true,
|
||||
defaults: true,
|
||||
enums: String,
|
||||
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
|
||||
includeDirs: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
|
||||
var testProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
@ -30,7 +30,7 @@ var protoPackage = protoLoader.loadSync(
|
||||
{keepCase: true,
|
||||
defaults: true,
|
||||
enums: String,
|
||||
include: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
|
||||
includeDirs: [__dirname + '/../../packages/grpc-native-core/deps/grpc']});
|
||||
var testProto = grpc.loadPackageDefinition(protoPackage).grpc.testing;
|
||||
|
||||
var ECHO_INITIAL_KEY = 'x-grpc-test-echo-initial';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user