Show:
Module: Autodocs

Methods

default
(
  • name
  • value
)
String

Set a default value for an environment variable if it does not exist

Parameters:

  • name String

    The name of the environment variable

  • value String

    The default value

Returns:

String:

The value of the existing or newly set environment variable

default
(
  • name
)
String

Substitute the value of other environment variables into the named one.

For example:

process.env.MAJOR_VERSION = "0";
                                    process.env.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 String

    The name of the environment variable

Returns:

String:

The value of the existing or newly set environment variable

exists
(
  • name
)
Boolean

Test that an environment variable exists

Parameters:

  • name String

    The name of the environment variable

Returns:

Boolean:

true when environment variable is defined and is not an empty string

require
(
  • name
)

Enforce that an environment variable exists

Parameters:

  • name String

    The name of the environment variable