This module exposes a CLI that can be run with yarn figaro
.
Using the heroku:set
command, you can set values from your configuration file all at once:
$ yarn figaro heroku:set -e production
For more information:
$ yarn figaro -h
A function that loads env variables into process.env
.
Internally calls read and merges the result into process.env
.
Options
load
may be passed an options object containing the following keys:
path
: The path to the config file (default: './config/application.yml')environment
: The string name of the current environment (default: 'development')
options
object Options for the function as specified above.
// Let's say we've got an application.yml that looks like:
// SOME_VAR: 'FOO'
const Figaro = require('figaro-js')
const path = require('path')
console.log(process.env.SOME_VAR) // -> undefined
Figaro.load({
path: path.resolve(__dirname, './application.yml')
})
console.log(process.env.SOME_VAR) // -> 'FOO'
*
A function that loads env variables from a file and returns an object containing them. The file may contain plain key-value pairs ("shared" variables) or key-values pairs nested under environment keys. The latter will only be loaded if the current environment matches the environment key.
Options
read
may be passed an options object containing the following keys:
path
: The path to the config file (default: './config/application.yml')environment
: The string name of the current environment (default: 'development')
options
object Options for the function as specified above.
// Let's say we've got an application.yml that looks like:
// SOME_VAR: 'FOO'
// development:
// IS_DEV: true
// production:
// IS_PROD: true
const Figaro = require('figaro-js')
const path = require('path')
const myEnv = Figaro.read({
path: path.resolve(__dirname, './application.yml')
})
console.log(myEnv)
// -> {
// SOME_VAR: 'FOO',
// IS_DEV: true
// }
*
A function that checks to make sure certain variables have been loaded into process.env
.
If they exist in process.env
, it returns true
; if not, it throws an exception.
keys
...string The required keys
if (requireKeys('MY_KEY', 'ANOTHER_KEY')) {
runProgram()
}
// Above will throw if 'MY_KEY', 'ANOTHER_KEY' are not keys in process.env.
*