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:

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 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

parsePrintenv
(
  • stdout
  • out
)
Object

In a bash shell, when printenv is invoked, parse its output into a Javascript object

Parameters:

  • stdout String

    The output from printenv

  • out String

    If this is given, the values from printenv will be added/ overriden ob this object

Returns:

Object:

A hash of key value pairs

require
(
  • name
)

Enforce that an environment variable exists

Parameters:

  • name String

    The name of the environment variable

selected
(
  • name
)
Object

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

Parameters:

  • name Array

    The names of the environment variables we want

Returns:

Object:

A hash of key value pairs