Start typing to search packages!
lune-dotenv
By @eggflaw
Roblox
Mirroredlune-dotenv
A dotenv parser for Lune
lune-dotenv loads environtment variables from a .env file and adds them into process.env.
[!WARNING] lune-dotenv is still in-development. Some features aren't implemented yet and there might be breaking changes to the API in the future.
Installation
Wally
Coming soon.
Git submodules
git submodule add https://github.com/Eggflaw/lune-dotenv.git
Usage
Create a .env file into the root directory of your project.
OPENCLOUD_KEY=OPENCLOUDKEYHERE
SECRETS="SECRETS"
You can now load the .env file with lune-dotenv
local process = require("@lune/process")
local dotenv = require("Packages/lune-dotenv") -- Assuming you added lune-dotenv into Packages/
dotenv:load() -- Must come before accessing process.env
print(process.env.OPENCLOUD_KEY) -- Remove after you confirmed it's working
API
dotenv:load(overwrite: boolean?, path: string?)
Loads a .env file and add it into process.env
By default, load will find a .env file in the current working directory
If there is an environment variable with the same key name, lune-dotenv will not overwrite it.
Set overwrite to true to avoid this.
dotenv:load(false)
print(process.env.HOME) -- "/home/yourname"
--============--
dotenv:load(true)
print(process.env.HOME) -- "NEWHOME"
You can give load a custom path instead of finding a .env in the current directory
dotenv:load(false, "tests/envs/path.env")
print(process.env.CUSTOM_PATH)
dotenv:parse(str: string): { [string?]: string? }
Parse .env content and convert it into a table.
Use this if you don't want to load .env into process.env
local content = fs.readFile(".env")
local env = dotenv:parse(content)
print(env)
TODO
- Basic values
- Multiline values
- Comments
- Variable Substitution
- Command Substitution
- Exports
References:
Package Details
Install command (Click to copy)
Version
0.1.0
License
MIT
Safe for commercial use
Automated license review — not legal advice.
