env-file-rw
Edit and read from .env files
Features
- Read key from .env file
- Write key/value to .env file
- Preserve comments
- Typescript
Sync example
const EnvFileWriter = require("env-file-rw");
const envFileWriter = new EnvFileWriter("test.env");
envFileWriter.get("HELLO","NOT WORLD");
envFileWriter.set("HELLO","WORLD");
envFileWriter.saveSync();
Async example
const EnvFileWriter = require("env-file-rw");
const envFileWriter = new EnvFileWriter("test.env",false);
await envFileWriter.parse();
envFileWriter.get("HELLO","NOT WORLD");
envFileWriter.set("HELLO","WORLD");
await envFileWriter.save();
Typescript example
import EnvFileWriter from "env-file-rw";
const envFileWriter = new EnvFileWriter< { HELLO : any} >("test.env",false);
await envFileWriter.parse();
envFileWriter.get("HELLO","NOT WORLD");
envFileWriter.set("HELLO","WORLD");
await envFileWriter.save();