Command line utility for automatically injecting environment variables into files. This allows you to easily keep sensitive parameters out of your config files and only add them as part of your build process.
You will need to have a recent version of Node.js
installed.
To get started install command line tool by running npm install -g replace-env
To replace all instances of %variable% in file run replace-env <filename>
.
You can add as many parameters in the format %variable_name% as you like.
Just make sure that all the environment variables are set in the shell before running tool.
Lets say you have text file called config.txt
that has the following contents:
# config.txt
PASSWORD=%PASSWORD_VAR%
TOKEN=%TOKEN_VAR%
You can temporarily set the needed variables by running the following:
export PASSWORD_VAR=top_secret
export TOKEN_VAR=xjW14@35z1
You can now run replace-env config.txt
and the file config.txt
should now have the following contents:
# config.txt
PASSWORD=top_secret
TOKEN=xjW14@35z1
- Dovid Gefen - Github Page
This project is licensed under the MIT License - see the LICENSE file for details