0.3.0 • Published 6 years ago
git-env v0.3.0
git-env
Use dotfiles per git branch
Setting up
Create an env file per flow branch. For example:
app
|- .dev.env
|- .qa.env
|- .master.envEach of these should be a UTF8 dotenv file.
Usage
You should probably create a top-level env.js that looks like so:
module.exports = require("git-env")("dev");The return value of this function is an object containing the parsed values from the env file, but the keys are camelCased.
The exported function from git-env accepts 2 paramters:
- fallback branch which will be the config loaded for every branch that doesn't have an
envfile (for example, if you branch out to a feature branch from dev). This should probably be your development branch's name. - options which is an object:
prefix(defaults to".") which is the part that comes before the branch namesuffix(defaults to".env") which is the part that comes after the branch namecwd(defaults toprocess.cwd()) which is the pathgit-envlooks for theenvfiles.
Notes
- If your directory doesn't have a
.gitdirectory (meaning it's not a git project), the branch name is_none_. - You can override the branch name detection (for testing, for example) using the GIT_ENV enviornment variable.