grunt-save-env
v0.1.0
Published
Saves process.env variables to a file called env.json
Downloads
2
Readme
grunt-save-env
Saves process.env variables to a file.
Background
There are tons of modules for loading and setting proces.env variables, but none (that I could find) for save them! We use this module to save data from Jenkins builds, for example BUILD_NUMBER and BUILD_NAME.
Getting Started
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-save-env --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-save-env');
The "save_env" task
Overview
In your project's Gruntfile, add a section named save_env
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
save_env: {
dest: 'env.json',
only: [],
exclude: []
},
});
Options
dest
String, will be the filename to write. Must be json file. Defaults to env.json
. This will not conflict with apps that load from .env
.
only
Array, will parse the process.env variables and return only those specified in array.
exclude
Array, variables that will not be included in the resulting file. Useful for protecting potential secure variables.
Todo
- Proper tests