Skip to content

Commit f3ca270

Browse files
fix: use require() to load JSON protos (#572)
The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Link: googleapis/googleapis@75880c3 Source-Link: googleapis/googleapis-gen@77b1804
1 parent 0a2fd4d commit f3ca270

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

packages/google-cloud-language/src/v1/language_service_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
2222
import * as path from 'path';
2323

2424
import * as protos from '../../protos/protos';
25+
import jsonProtos = require('../../protos/protos.json');
2526
/**
2627
* Client JSON configuration object, loaded from
2728
* `src/v1/language_service_client_config.json`.
@@ -136,22 +137,7 @@ export class LanguageServiceClient {
136137
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
137138
}
138139
// Load the applicable protos.
139-
// For Node.js, pass the path to JSON proto file.
140-
// For browsers, pass the JSON content.
141-
142-
const nodejsProtoPath = path.join(
143-
__dirname,
144-
'..',
145-
'..',
146-
'protos',
147-
'protos.json'
148-
);
149-
this._protos = this._gaxGrpc.loadProto(
150-
opts.fallback
151-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
152-
require('../../protos/protos.json')
153-
: nodejsProtoPath
154-
);
140+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
155141

156142
// Put together the default options sent with requests.
157143
this._defaults = this._gaxGrpc.constructSettings(

packages/google-cloud-language/src/v1beta2/language_service_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
2222
import * as path from 'path';
2323

2424
import * as protos from '../../protos/protos';
25+
import jsonProtos = require('../../protos/protos.json');
2526
/**
2627
* Client JSON configuration object, loaded from
2728
* `src/v1beta2/language_service_client_config.json`.
@@ -136,22 +137,7 @@ export class LanguageServiceClient {
136137
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
137138
}
138139
// Load the applicable protos.
139-
// For Node.js, pass the path to JSON proto file.
140-
// For browsers, pass the JSON content.
141-
142-
const nodejsProtoPath = path.join(
143-
__dirname,
144-
'..',
145-
'..',
146-
'protos',
147-
'protos.json'
148-
);
149-
this._protos = this._gaxGrpc.loadProto(
150-
opts.fallback
151-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
152-
require('../../protos/protos.json')
153-
: nodejsProtoPath
154-
);
140+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
155141

156142
// Put together the default options sent with requests.
157143
this._defaults = this._gaxGrpc.constructSettings(

0 commit comments

Comments
 (0)