DefinitelyTyped/types/dotenv-safe/index.d.ts
Fredrik Ohlin 404d5f02d7
🤖 Merge PR #46259 [dotenv-safe] Extend DotenvConfigOutput to match dotenv-safe output by @fohlin
* Extend DotenvConfigOutput to match dotenv-safe output

The return value of dotenv-safe.config() extends dotenv.config() by adding a `required` property, which is now reflected in the type structure.

Reference https://github.com/rolodato/dotenv-safe#usage

* Apply prettier on dotenv-safe

npm run prettier -- --write 'types/dotenv-safe/**/*.ts'
2020-07-28 11:00:33 -04:00

54 lines
1.3 KiB
TypeScript

// Type definitions for dotenv-safe 8.1
// Project: https://github.com/rolodato/dotenv-safe
// Definitions by: Stan Goldmann <https://github.com/krenor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import dotenv = require('dotenv');
export interface MissingEnvVarsError extends Error {
/**
* Path to example environment file.
*/
sample: string;
/**
* Variables which existing in the sample file, but not in the loaded file.
*/
missing: string[];
}
export interface DotenvSafeOptions extends dotenv.DotenvConfigOptions {
/**
* Path to example environment file. (Option 1)
* @default ".env.example"
*/
example?: string;
/**
* Path to example environment file. (Option 2 -- example takes precedence)
* @default ".env.example"
*/
sample?: string;
/**
* Enabling this option will not throw an error after loading.
* @default false
*/
allowEmptyValues?: boolean;
}
export interface DotenvSafeConfigOutput extends dotenv.DotenvConfigOutput {
/**
* key-value pairs required by .env.example
*/
required: dotenv.DotenvParseOutput;
}
/**
* Loads environment variables file into 'process.env'.
*
* @throws MissingEnvVarsError
*/
export function config(options?: DotenvSafeOptions): DotenvSafeConfigOutput;