EnvironmentVariables
Table of Contents
Methods
default
-
name
-
value
Set a default value for an environment variable if it does not exist
Parameters:
-
name
StringThe name of the environment variable
-
value
StringThe 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:
-
name
StringThe 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:
-
name
StringThe 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:
-
stdout
StringThe output from
printenv
-
out
StringIf this is given, the values from
printenv
will be added/ overriden ob this object
Returns:
A hash of key value pairs
require
-
name
Enforce that an environment variable exists
Parameters:
-
name
StringThe name of the environment variable
selected
-
name
Set a default value for an environment variable if it does not exist
Parameters:
-
name
ArrayThe names of the environment variables we want
Returns:
A hash of key value pairs