#env-file #env #load #loading #cli

app load-env

A tool to load .env files

2 unstable releases

0.3.0 May 5, 2023
0.2.0 Apr 4, 2023
0.1.0 Apr 4, 2023

#1605 in Command line utilities

Download history 8/week @ 2024-02-19 24/week @ 2024-02-26 2/week @ 2024-03-11 49/week @ 2024-04-01

51 downloads per month

ISC license

4KB
50 lines

load-env

CLI wrapper for loading .env files, written in rust

Install

Install globally with cargo:

cargo install load-env

Usage

Create .env file in your project:

DATABASE_URL="postgres://user:password@host:port/db"

Load the .env with cli:

load-env <your-command>

Nesting and mode

You can use the naming convention for .env files, such as in nextjs, Vite, etc.

For example, create a .env.local for local usage:

# .env.local

DATABASE_URL="postgres://user:password@host:port/db-local"

and .env.test.local for run tests:

# .env.test.local

DATABASE_URL="postgres://user:password@host:port/db-test"

.env.local will be loaded in any case, for load .env.test.local you need to specify the mode flag:

load-env -m test <your-command>

Env Loading Priorities

.env                # loaded in all cases
.env.local          # loaded in all cases, ignored by git
.env.[mode]         # only loaded in specified mode
.env.[mode].local   # only loaded in specified mode, ignored by git

Dependencies

~48KB