From d82aaea389bc687f2082120dc0414cfb1b00f87c Mon Sep 17 00:00:00 2001 From: Young Yu Date: Fri, 9 Feb 2024 13:43:15 -0800 Subject: [PATCH] allow env command line arg to set NODE_ENV env var --- CHANGELOG.md | 3 +++ README.md | 2 +- package.json | 2 +- src/simple-app-config.ts | 3 +++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e49f75..e116b1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 4cf84fe..c918383 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/package.json b/package.json index c6e41f2..f19848a 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/simple-app-config.ts b/src/simple-app-config.ts index 7ba3d65..a3f1719 100644 --- a/src/simple-app-config.ts +++ b/src/simple-app-config.ts @@ -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();