Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

shenv

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shenv

Posix compatible shell script that makes loading environment variables from multiple .env files easy, while respecting ones already set.

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

shenv

Posix compatible shell script that makes loading environment variables from multiple .env files easy, while respecting ones already set.

Environment files are a handy way in local development to define the configurable values. They are important to the concept of the 12 factor app. Within node development the npm dotenv package makes loading multiple of such files easy while not overwriting values from the host environment. However loading such files in a shell environment is tricky. This utility shell script makes that easy.

Install

npm install shenv

Usage

Set up of example host environment and .env files.

export ENV_1=host

echo '
ENV_1=a
ENV_2=a
' > a.env

echo '
ENV_2=b
ENV_3=b
' > b.env

Load all that into the current shell context with:

eval $(./shenv.sh a.env b.env)

Break Down

In the above example shenv.sh will output:

export ENV_2=a
export ENV_3=b

By executing shenv.sh in a subshell with eval $(./shenv ...) the export string above is eval'd and the values are available as environment variables in the current shell's context.

Compatibility

The output is posix compatible shell export commands that has been tested compatible with safe characters. Further testing is need for things like unicode support.

The objective is to load environment files that meet the dotenv Rules.

FAQs

Package last updated on 17 Aug 2017

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