Attributes
Extremely Popular
Repository
Current version released
6 years ago
Dependencies
deno.land/x
Dotenv 
Dotenv handling for deno.
Usage
Setup a .env file in the root of your project.
.env
GREETING=hello worldThen import the configuration using the config function.
app.ts
import { config } from "https://raw.githubusercontent.com/pietvanzoen/deno-dotenv/v0.0.2/dotenv.ts";
console.log(config());Then run your app.
> deno app.ts
{ GREETING: "hello world" }Options
path?: string: Optional path to.envfile. Defaults to./.env.export?: boolean: Set totrueto export all.envvariables to the current processes environment. Variables are then accessable via deno’senvfunction. Defaults tofalse.
Parsing Rules
The parsing engine currently supports the following rules:
BASIC=basicbecomes{BASIC: 'basic'}- empty lines are skipped
- lines beginning with
#are treated as comments - empty values become empty strings (
EMPTY=becomes{EMPTY: ''}) - single and double quoted values are escaped (
SINGLE_QUOTE='quoted'becomes{SINGLE_QUOTE: "quoted"}) - new lines are expanded if in double quotes (
MULTILINE="new\nline"becomes
{MULTILINE: 'new
line'}- inner quotes are maintained (think JSON) (
JSON={"foo": "bar"}becomes{JSON:"{\"foo\": \"bar\"}") - whitespace is removed from both ends of the value (see more on
trim) (FOO=" some value "becomes{FOO: 'some value'})
Contributing
Issues and pull requests welcome. Please run make fmt before commiting.
Credit
- Inspired by the node module
dotenv.