1.0.2 • Published 4 years ago

parsenv v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

ParsEnv

License: MIT

Edit, Save or Load variables from .env ( For Nodejs )

WHY I CREATE THIS

Since 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

const dotenv = require("parsenv");

Edit variables

const dotenv = require("parsenv");

dotenv.edit({ VARIABLE: "value", ANOTHER: "another" });

Save variables

const dotenv = require("parsenv");

dotenv.write();

EXAMPLE

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

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 for more information.