Skip to content

Commit 6396812

Browse files
fix: use require() to load JSON protos (#301)
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 596d025 commit 6396812

File tree

3 files changed

+6
-48
lines changed

3 files changed

+6
-48
lines changed

packages/google-devtools-containeranalysis/src/v1/container_analysis_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import * as path from 'path';
2323
import {GrafeasClient} from '@google-cloud/grafeas';
2424

2525
import * as protos from '../../protos/protos';
26+
import jsonProtos = require('../../protos/protos.json');
2627
/**
2728
* Client JSON configuration object, loaded from
2829
* `src/v1/container_analysis_client_config.json`.
@@ -149,22 +150,7 @@ export class ContainerAnalysisClient {
149150
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
150151
}
151152
// Load the applicable protos.
152-
// For Node.js, pass the path to JSON proto file.
153-
// For browsers, pass the JSON content.
154-
155-
const nodejsProtoPath = path.join(
156-
__dirname,
157-
'..',
158-
'..',
159-
'protos',
160-
'protos.json'
161-
);
162-
this._protos = this._gaxGrpc.loadProto(
163-
opts.fallback
164-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
165-
require('../../protos/protos.json')
166-
: nodejsProtoPath
167-
);
153+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
168154

169155
// This API contains "path templates"; forward-slash-separated
170156
// identifiers to uniquely identify resources within the API.

packages/google-devtools-containeranalysis/src/v1beta1/container_analysis_v1_beta1_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import * as path from 'path';
3131
import {Transform} from 'stream';
3232
import {RequestType} from 'google-gax/build/src/apitypes';
3333
import * as protos from '../../protos/protos';
34+
import jsonProtos = require('../../protos/protos.json');
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1beta1/container_analysis_v1_beta1_client_config.json`.
@@ -158,22 +159,7 @@ export class ContainerAnalysisV1Beta1Client {
158159
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
159160
}
160161
// Load the applicable protos.
161-
// For Node.js, pass the path to JSON proto file.
162-
// For browsers, pass the JSON content.
163-
164-
const nodejsProtoPath = path.join(
165-
__dirname,
166-
'..',
167-
'..',
168-
'protos',
169-
'protos.json'
170-
);
171-
this._protos = this._gaxGrpc.loadProto(
172-
opts.fallback
173-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
174-
require('../../protos/protos.json')
175-
: nodejsProtoPath
176-
);
162+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
177163

178164
// This API contains "path templates"; forward-slash-separated
179165
// identifiers to uniquely identify resources within the API.

packages/google-devtools-containeranalysis/src/v1beta1/grafeas_v1_beta1_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import * as path from 'path';
3131
import {Transform} from 'stream';
3232
import {RequestType} from 'google-gax/build/src/apitypes';
3333
import * as protos from '../../protos/protos';
34+
import jsonProtos = require('../../protos/protos.json');
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1beta1/grafeas_v1_beta1_client_config.json`.
@@ -158,22 +159,7 @@ export class GrafeasV1Beta1Client {
158159
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
159160
}
160161
// Load the applicable protos.
161-
// For Node.js, pass the path to JSON proto file.
162-
// For browsers, pass the JSON content.
163-
164-
const nodejsProtoPath = path.join(
165-
__dirname,
166-
'..',
167-
'..',
168-
'protos',
169-
'protos.json'
170-
);
171-
this._protos = this._gaxGrpc.loadProto(
172-
opts.fallback
173-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
174-
require('../../protos/protos.json')
175-
: nodejsProtoPath
176-
);
162+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
177163

178164
// This API contains "path templates"; forward-slash-separated
179165
// identifiers to uniquely identify resources within the API.

0 commit comments

Comments
 (0)