Skip to content

Commit 9963b9c

Browse files
committed
fix(ElasticApiParser): Add elasticApiFilesPath option
1 parent 4e5a370 commit 9963b9c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ElasticApiParser.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type ElasticApiParserOptsT = {
3939
| '1_0'
4040
| '0_90',
4141
prefix?: string,
42+
elasticApiFilesPath?: string,
4243
};
4344

4445
export type ElasticParamConfigT = {
@@ -63,26 +64,26 @@ export type ElasticCaSettingsT = {
6364
urls?: ElasticCaSettingsUrlT[],
6465
};
6566

66-
export const elasticApiFilesPath = './node_modules/elasticsearch/src/lib/apis/';
67-
6867
export default class ElasticApiParser {
6968
cachedEnums: {
7069
[fieldName: string]: { [valsStringified: string]: GraphQLEnumType },
7170
};
7271
version: string;
7372
prefix: string;
73+
elasticApiFilesPath: string;
7474

7575
constructor(opts: ElasticApiParserOptsT = {}) {
7676
// derived from installed package `elasticsearch`
7777
// from ../../node_modules/elasticsearch/src/lib/apis/VERSION.js
7878
this.version = opts.version || '5_0';
7979
this.prefix = opts.prefix || 'Elastic';
80+
this.elasticApiFilesPath = opts.elasticApiFilesPath || './node_modules/elasticsearch/src/lib/apis/';
8081
this.cachedEnums = {};
8182
}
8283

8384
run() {
8485
this.cachedEnums = {};
85-
const apiFilePath = path.resolve(elasticApiFilesPath, `${this.version}.js`);
86+
const apiFilePath = path.resolve(this.elasticApiFilesPath, `${this.version}.js`);
8687
const source = this.loadApiFile(apiFilePath);
8788
return this.parseSource(source);
8889
}

0 commit comments

Comments
 (0)