DotEnvUtils
A utility class/service to work with .env files for environment variables.
Constructor Summary
Public Constructor | ||
public |
constructor(environmentUtils: EnvironmentUtils, appLogger: AppLogger, pathUtils: PathUtils) |
Method Summary
Public Methods | ||
public |
Given a dictionary of variables, this method will inject all of them on the environment. |
|
public |
Given a list of |
Public Constructors
public constructor(environmentUtils: EnvironmentUtils, appLogger: AppLogger, pathUtils: PathUtils) source
Params:
Name | Type | Attribute | Description |
environmentUtils | EnvironmentUtils | To set variables in the environment. |
|
appLogger | AppLogger | To log information messages when files are loaded or when there's a problem loading them. |
|
pathUtils | PathUtils | To get paths relative to the project root. |
Public Methods
public inject(variables: Object, overwrite: boolean) source
Given a dictionary of variables, this method will inject all of them on the environment.
public load(files: Array, extend: boolean): Object source
Given a list of .env
files (relative to the project root directory), this method will
validate if they exist, load them, merge them (if extend
is true
) and return an object
with all the variable declarations it found.
Params:
Name | Type | Attribute | Description |
files | Array | The list of file names relative to the project root directory. |
|
extend | boolean |
|
Whether or not the variables found on the files should be
merged on a single object. If this is |