Skip to content

Commit

Permalink
Allow ES module export of client
Browse files Browse the repository at this point in the history
  • Loading branch information
rbayliss committed Dec 31, 2019
1 parent a06b90e commit f90a729
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cli.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export function getClient(argv: Configuration) {
return new Client({node: argv.elasticsearch});
}
else {
return require(join(argv.root, argv.elasticsearch))
let client = require(join(argv.root, argv.elasticsearch))
if(!client) {
throw new Error(`Unable to load client from ${argv.elasticsearch}. Did you mean to export a client object?`)
}
return 'default' in client ? client.default : client
}
}
return new Client(argv.elasticsearch);
Expand Down

0 comments on commit f90a729

Please sign in to comment.