Skip to content

stopthatastronaut/poshdotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotEnv

A simple PowerShell module enabling loading of .env files into a PowerShell session. Takes inspiration from the node norm of env files. It simply picks up your key value pairs from .env, and loads them into transient environment variables. They can be optionally cleaned up at the end of the session, or the session can just be destroyed.

How To Use

Install, call.

Install

Find-Module dotenv

Install-Module dotenv

Use

Import-Module dotenv
Set-DotEnv # loads from the local .env file
# code here
Remove-DotEnv # clears the variables that were loaded by set-dotenv

Advanced scenarios

If you want to keep several .env files alongside your repo, you can use the path parameter to load a specific file.

Import-Module dotenv
Set-DotEnv -Path ./env.staging
# code here
Remove-DotEnv

Escaping

This module can handle values with an extra '=' in them, and can handle quoted strings (single and double). For more complex scenarios, it may be advisable to base64 encode the values, and then decode as they're needed.

Coming Soon

  • Allow append and prepend with :=/=: syntax
  • Extra testing, especially around injection of 'bad' vars, because we're dealing with possible third-party input here

Contributing

Contribs welcome, please put in a PR and notify @cloudyopspoet on Twitter that you've done it, as notifications don't always make it through from github.

About

Simple PowerShell Module to load from .env files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published