e2f3b4d11242bf371f81adaa0a204f3ec218f63abc8a7af8f9cd661b6d07439f18191d36f0579165101ec108ff099e9b232109d990c50980f207daa2a319a7 1.6 KB

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