Skip to content

Commit c83bbfb

Browse files
anacasnerawolden
authored andcommitted
feat(EurekaClient.js): Allow an independent EUREKA_ENV env variable. (#151)
* feat(EurekaClient.js): Allow an independent EUREKA_ENV env variable. This allows developers to select whatever Eureka env/config they need without having to rely on NODE_ENV. For example, we can set EUREKA_ENV to 'test', but keep NODE_ENV='production' for all the middleware and components in our library. * docs(README.md): Explained how to use env variables to pick configs * 4.5.0
1 parent 230973f commit c83bbfb

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const client = new Eureka({
4444
});
4545
```
4646

47-
The Eureka client searches for the YAML file `eureka-client.yml` in the current working directory. It further searches for environment specific overrides in the environment specific YAML files (e.g. `eureka-client-test.yml`). The environment is typically `development` or `production`, and is determined by the `NODE_ENV` environment variable. The options passed to the constructor overwrite any values that are set in configuration files.
47+
The Eureka client searches for the YAML file `eureka-client.yml` in the current working directory. It further searches for environment specific overrides in the environment specific YAML files (e.g. `eureka-client-test.yml`). The environment is typically `development` or `production`, and is determined by environment variables in this order: `EUREKA_ENV`, if present, or `NODE_ENV`, if present. Otherwise it defaults to `development`. The options passed to the constructor overwrite any values that are set in configuration files.
4848

4949
You can configure a custom directory to load the configuration files from by specifying a `cwd` option in the object passed to the `Eureka` constructor.
5050

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eureka-js-client",
3-
"version": "4.4.2",
3+
"version": "4.5.0",
44
"description": "A JavaScript implementation the Netflix OSS service registry, Eureka.",
55
"main": "lib/index.js",
66
"scripts": {

src/EurekaClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class Eureka extends EventEmitter {
5454

5555
// Load up the current working directory and the environment:
5656
const cwd = config.cwd || process.cwd();
57-
const env = process.env.NODE_ENV || 'development';
57+
const env = process.env.EUREKA_ENV || process.env.NODE_ENV || 'development';
5858

5959
const filename = config.filename || 'eureka-client';
6060

0 commit comments

Comments
 (0)