https://github.com/heinthanth/parsenv-node
Edit, Save or Load variables from .env ( For Nodejs )
https://github.com/heinthanth/parsenv-node
Last synced: 5 months ago
JSON representation
Edit, Save or Load variables from .env ( For Nodejs )
- Host: GitHub
- URL: https://github.com/heinthanth/parsenv-node
- Owner: heinthanth
- License: mit
- Created: 2020-10-10T14:40:03.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-11T07:53:03.000Z (over 5 years ago)
- Last Synced: 2024-12-29T18:56:06.472Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ParsEnv
[](LICENSE)
Edit, Save or Load variables from .env ( For Nodejs )
## WHY I CREATE THIS
Since [motdotla/dotenv](https://github.com/motdotla/dotenv) can load variables from .env but can't save modified variables into .env, I just want to create this stuff.
## USAGE
### Load variables
```javascript
const dotenv = require("parsenv");
```
### Edit variables
```javascript
const dotenv = require("parsenv");
dotenv.edit({ VARIABLE: "value", ANOTHER: "another" });
```
### Save variables
```javascript
const dotenv = require("parsenv");
dotenv.write();
```
## EXAMPLE
```javascript
const parsenv = require("../src");
const p = require("path");
parsenv.config();
parsenv.edit({ NAME: "NAME CHANGED", ANOTHER_VARIABLE: "BAZ" });
parsenv.write({ path: p.join(__dirname, "../.env.modified") });
```
## CONFIGURATION
```javascript
const dotenv = require("parsenv");
const config = {
path: require('path').resolve(process.cwd(), ".env") // default
encoding: 'utf8' // default
debug: false // default
};
// config can apply to dotenv.config function
dotenv.config(config);
// also pass it to dotenv.write function
dotenv.write(config);
```
These settings and variables can be modified through `global.parsenv.setting` and `global.parsenv.env`. But recommend `edit` method to change variable
## LICENSE
`ParsEnv` is licensed under the MIT license. See [License](LICENSE) for more information.