requireEnvBoolean()function

requireEnvBoolean(name: string, caller: AnyCaller = requireEnvBoolean): boolean
ParamType
namestring
Name of the environment variable to read. required
callerAnyCaller
Function to attribute a thrown error to (defaults to requireEnvBoolean). Defaults to requireEnvBoolean
Return
boolean
false if the environment variable is 0, off, no, false; true if it is 1, on, yes, true.
Throws
unknown
RequiredError if the env variable is any other value.

Get a process.env variable and resolve it to true or false, or throw RequiredError if it isn't a true/false value.

Examples

requireEnvBoolean("FEATURE_FLAG") // true