1 | // TypeScript Version: 3.0
|
2 | /// <reference types="node" />
|
3 |
|
4 | export interface DotenvParseOptions {
|
5 | /**
|
6 | * You may turn on logging to help debug why certain keys or values are not being set as you expect.
|
7 | */
|
8 | debug?: boolean;
|
9 | }
|
10 |
|
11 | export interface DotenvParseOutput {
|
12 | [name: string]: string;
|
13 | }
|
14 |
|
15 | /**
|
16 | * Parses a string or buffer in the .env file format into an object.
|
17 | *
|
18 | * @param src - contents to be parsed
|
19 | * @param options - additional options
|
20 | * @returns an object with keys and values based on `src`
|
21 | */
|
22 | export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
|
23 | src: string | Buffer,
|
24 | options?: DotenvParseOptions
|
25 | ): T;
|
26 |
|
27 | export interface DotenvConfigOptions {
|
28 | /**
|
29 | * You may specify a custom path if your file containing environment variables is located elsewhere.
|
30 | */
|
31 | path?: string;
|
32 |
|
33 | /**
|
34 | * You may specify the encoding of your file containing environment variables.
|
35 | */
|
36 | encoding?: string;
|
37 |
|
38 | /**
|
39 | * You may turn on logging to help debug why certain keys or values are not being set as you expect.
|
40 | */
|
41 | debug?: boolean;
|
42 | }
|
43 |
|
44 | export interface DotenvConfigOutput {
|
45 | error?: Error;
|
46 | parsed?: DotenvParseOutput;
|
47 | }
|
48 |
|
49 | /**
|
50 | * Loads `.env` file contents into {@link https://nodejs.org/api/process.html#process_process_env `process.env`}.
|
51 | * Example: 'KEY=value' becomes { parsed: { KEY: 'value' } }
|
52 | *
|
53 | * @param options - controls behavior
|
54 | * @returns an object with a `parsed` key if successful or `error` key if an error occurred
|
55 | *
|
56 | */
|
57 | export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
|
58 | /** @deprecated since v7.0.0 Use config instead. */
|
59 | export const load: typeof config;
|