Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

editenv

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

editenv

EditEnv is a simple and efficient Node.js library for loading, parsing, editing, and saving .env files. Ideal for programmatically managing environment variables in your projects.

  • 0.0.12
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
0
Weekly downloads
 
Created
Source

EditEnv

EditEnv is a simple and efficient Node.js library for loading, parsing, editing, and saving .env files. Ideal for programmatically managing environment variables in your projects.

logo

Installation

npm install editenv

Usage

CommonJS

If you are using CommonJS modules (e.g., in Node.js environments that use require), you can use the library like this:

const { EditEnvLoad, EditEnvAsJson, EditEnvGet, EditEnvSet } = require('editenv');

EditEnvLoad('./.env');
EditEnvAsJson('./.env');
EditEnvGet('./.env', 'EXISTING_KEY');
EditEnvSet('./.env', 'EXISTING_KEY', 'new_value');
EditEnvSet('./.env', 'NEW_KEY', 'new_value');

ES6 Modules

If you are using ES6 modules (e.g., in environments that support import), you can use the library like this:

import { EditEnvLoad, EditEnvAsJson, EditEnvGet, EditEnvSet } from 'editenv';

EditEnvLoad('./.env');
EditEnvAsJson('./.env');
EditEnvGet('./.env', 'EXISTING_KEY');
EditEnvSet('./.env', 'EXISTING_KEY', 'new_value');
EditEnvSet('./.env', 'NEW_KEY', 'new_value');

API

EditEnvLoad(filePath)

Loads the content of the .env file located at filePath.

EditEnvAsJson(filePath)

Parses the .env file located at filePath and returns its contents as a JSON object.

EditEnvGet(filePath, key)

Gets the value associated with key from the .env file located at filePath.

EditEnvSet(filePath, key, value)

Sets the value for key in the .env file located at filePath. If the key does not exist, it is added.

FAQs

Package last updated on 31 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc