https://github.com/coursedesign/config-importer
Developers can manage environment variables in various stages, such as production, test, development, etc.
https://github.com/coursedesign/config-importer
config config-management configuration configuration-management
Last synced: about 2 months ago
JSON representation
Developers can manage environment variables in various stages, such as production, test, development, etc.
- Host: GitHub
- URL: https://github.com/coursedesign/config-importer
- Owner: CourseDesign
- License: mit
- Created: 2019-11-11T05:29:39.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-19T20:58:02.000Z (over 2 years ago)
- Last Synced: 2024-05-28T20:49:05.687Z (over 1 year ago)
- Topics: config, config-management, configuration, configuration-management
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@araxsiyual/config-importer
- Size: 21.5 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Config Importer 
Developers can manage environment variables in various stages, such as production, test, development, etc. Developers can set default status by option or NODE_ENV. if you not set default status, it will be development Environment variables are created in the common.js and `yourEnvironmentStatus`.js However, if an environment variable is declared in an .env file or a system environment variable, that value takes precedence.
## How to use
```javascript
const configImporter = require('@araxsiyual/config-importer');const config = configImporter.import(__dirname, /*option*/);
```## Option
```javascript
{
"env";: process.env.NODE_ENV || "development",
"valueName";: "valueName",
"default";: "common"
}
```- `env`: Environment status, it will read `env`.js file, and make config
- `valueName`: If object have `valueName`, module use `valueName`'s value for read System value or .env, If the object does not have a `valueName`, module use object name for read System value or .env
- `default`: default environment file name## Example
### Import the right environment variable
#### common.js
```javascript
module.exports = {
parent: {
childA: 0,
childB: 0
}
}
```#### development.js
```javascript
module.exports = {
parent: {
childA: 1
}
}
```#### test.js
```javascript
module.exports = {
parent: {
childA: 2
}
}
```#### index.js
```javascript
const configImporter = require('@araxsiyual/config-importer');const config = configImporter.import(__dirname);
module.exports = config;
```#### If development status is `development`
- **config is**
```javascript
{
{
1,
childB;: 0
}
}
```#### If development status is `test`
- **config is**
```javascript
{
{
2,
childB;: 0
}
}
```### .env file variable name
#### common.js
```javascript
module.exports = {
parent: {
childA: 0
}
}
```#### .env
```
PARENT_CHILD_A = 1
```- parent.childA will be 1
#### if development status is `development`
#### .env
```
PARENT_CHILD_A = 1
PARENT_CHILD_A_DEVELOPMENT = 2
```- parent.childA will be 2
### Set value name
#### common.js
```javascript
module.exports = {
parent: {
valueName: 'p',
childA: 0
}
}
```#### .env
```
P_CHILD_A = 1
```- parent.childA will be 1