FileSource
Default environment source on Node, Bun, and Deno: a snapshot of process.env. Because
supportsFiles is true, envapt also loads the .env cascade and resolves baseDir.
A key set in process.env wins over the same key in a file unless envFileOptions.override is
true. Envapter.syncProcessEnv can copy loaded keys back to process.env.
See
https://envapt.materwelon.dev/docs/sources#the-sources-envapt-ships
Implements
FileCapableSource
Constructors
Constructor
new FileSource(): FileSource;Returns
FileSource
Properties
Methods
normalizeBaseDir()
normalizeBaseDir(value): string;Resolves a directory path or a module / file: URL to an absolute directory. A file: URL
resolves to its containing directory. A plain path (import.meta.dirname) is taken as the
directory itself.
Parameters
| Parameter | Type |
|---|---|
value | string | URL |
Returns
string
Implementation of
FileCapableSource.normalizeBaseDirreadFile()
readFile(path, encoding): string | undefined;Reads a file with fs.readFileSync, or undefined when it is missing or unreadable.
Parameters
| Parameter | Type |
|---|---|
path | string |
encoding | string |
Returns
string | undefined
Implementation of
FileCapableSource.readFilereadVars()
readVars(): Record<string, string>;Returns a copy of process.env.
Returns
Record<string, string>
Implementation of
FileCapableSource.readVarsresolvePath()
resolvePath(baseDir, candidate): string;Joins a relative .env path onto baseDir. Absolute paths pass through unchanged.
Parameters
| Parameter | Type |
|---|---|
baseDir | string |
candidate | string |
Returns
string
Implementation of
FileCapableSource.resolvePathwriteVars()
writeVars(vars): void;Writes each key to process.env. Envapter.syncProcessEnv calls it.
Parameters
| Parameter | Type |
|---|---|
vars | Record<string, string> |
Returns
void
Implementation of
FileCapableSource.writeVars