Skip to content

Commit

Permalink
allow env command line arg to set NODE_ENV env var
Browse files Browse the repository at this point in the history
  • Loading branch information
youngbryanyu committed Feb 9, 2024
1 parent 76fb2f1 commit d82aaea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.2.0 - 2/9/24
Environment override in command line args no sets NODE_ENV environment variable

## 1.1.5 - 1/20/24
Fix grammar issues in documentation

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ node dist/index.js --config-path=test/config.json
```

### --env
The `--env` command line argument can be set to override the environment determined by the module. This will override the environment set by the `NODE_ENV` environment variable.
The `--env` command line argument can be set to override the environment determined by the module. This will override the environment set by the `NODE_ENV` environment variable. This will also set the `NODE_ENV` environment variable.

```bash
node dist/index.js --env=production
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-app-config",
"version": "1.1.5",
"version": "1.2.0",
"description": "A simple configuration manager for different environments",
"license": "MIT",
"repository": {
Expand Down
3 changes: 3 additions & 0 deletions src/simple-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export class Config {
Config.loadDefaultConfigFile(); /* Load default config file */
Config.alreadyConfigured = true; /* Set the alrady configured flag to true */

/* Set the NODE_ENV environment var */
EnvParser.setValue(EnvArgs.Env, Config.environment);

/* Initialize singleton instance */
if (Config.instance === undefined) {
Config.instance = new Config();
Expand Down

0 comments on commit d82aaea

Please sign in to comment.