EnvironmentVariables
Table of Contents
Methods
default
-
name -
value
Set a default value for an environment variable if it does not exist
Parameters:
-
nameStringThe name of the environment variable
-
valueStringThe default value
Returns:
The value of the existing or newly set environment variable
default
-
name
Substitute the value of other environment variables into the named one.
For example:
vars.MAJOR_VERSION = "0";
vars.MINOR_VERSION = "3";
EnvironmentVariables.substitute('api/.');
... will return 'api/0.3';
Note that if this is done for multiple environment variables, the order in which they are done will affect the result. It is the responsibility of the caller to this function to ensure that the values to be substituted in are already fully resolved: this function is not recursive. Therefore, cycles are also not allowed. Any of these will result in indeterminate results, including errors.
Parameters:
-
nameStringThe name of the environment variable
Returns:
The value of the existing or newly set environment variable
exists
-
name
Test that an environment variable exists
Parameters:
-
nameStringThe name of the environment variable
Returns:
true when environment variable is defined and is not an empty string
parsePrintenv
-
stdout -
out
In a bash shell, when printenv is invoked,
parse its output into a Javascript object
Parameters:
-
stdoutStringThe output from
printenv -
outStringIf this is given, the values from
printenvwill be added/ overriden ob this object
Returns:
A hash of key value pairs
require
-
name
Enforce that an environment variable exists
Parameters:
-
nameStringThe name of the environment variable
selected
-
name
Set a default value for an environment variable if it does not exist
Parameters:
-
nameArrayThe names of the environment variables we want
Returns:
A hash of key value pairs