版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.d.ts 2.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // TypeScript Version: 3.0
  2. /// <reference types="node" />
  3. export interface DotenvParseOutput {
  4. [name: string]: string;
  5. }
  6. /**
  7. * Parses a string or buffer in the .env file format into an object.
  8. *
  9. * See https://docs.dotenv.org
  10. *
  11. * @param src - contents to be parsed. example: `'DB_HOST=localhost'`
  12. * @param options - additional options. example: `{ debug: true }`
  13. * @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
  14. */
  15. export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
  16. src: string | Buffer
  17. ): T;
  18. export interface DotenvConfigOptions {
  19. /**
  20. * Default: `path.resolve(process.cwd(), '.env')`
  21. *
  22. * Specify a custom path if your file containing environment variables is located elsewhere.
  23. *
  24. * example: `require('dotenv').config({ path: '/custom/path/to/.env' })`
  25. */
  26. path?: string;
  27. /**
  28. * Default: `utf8`
  29. *
  30. * Specify the encoding of your file containing environment variables.
  31. *
  32. * example: `require('dotenv').config({ encoding: 'latin1' })`
  33. */
  34. encoding?: string;
  35. /**
  36. * Default: `false`
  37. *
  38. * Turn on logging to help debug why certain keys or values are not being set as you expect.
  39. *
  40. * example: `require('dotenv').config({ debug: process.env.DEBUG })`
  41. */
  42. debug?: boolean;
  43. /**
  44. * Default: `false`
  45. *
  46. * Override any environment variables that have already been set on your machine with values from your .env file.
  47. *
  48. * example: `require('dotenv').config({ override: true })`
  49. */
  50. override?: boolean;
  51. }
  52. export interface DotenvConfigOutput {
  53. error?: Error;
  54. parsed?: DotenvParseOutput;
  55. }
  56. /**
  57. * Loads `.env` file contents into process.env.
  58. *
  59. * See https://docs.dotenv.org
  60. *
  61. * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }`
  62. * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
  63. *
  64. */
  65. export function config(options?: DotenvConfigOptions): DotenvConfigOutput;