Signature
Parameters
The name of the environment variable to read
Optional fallback array if the environment variable is not set. If not provided and the variable is missing, an error will be thrown.
Returns
An array of strings parsed from the comma-separated environment variable or fallback
Behavior
- Reads the environment variable and trims whitespace
- Falls back to a comma-joined string of the fallback array if the variable is not set
- Throws an error if both the variable and fallback are missing
- Splits the string by commas
- Trims whitespace from each individual string
- Filters out empty strings after trimming
Error Handling
- Throws
Errorwith message"$KEY is missing"when the environment variable is not set and no fallback is provided
