Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#46259 [dotenv-safe] Extend DotenvConfigOut…
Browse files Browse the repository at this point in the history
…put 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'
  • Loading branch information
fohlin committed Jul 28, 2020
1 parent 3db3316 commit 404d5f0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
10 changes: 5 additions & 5 deletions types/dotenv-safe/dotenv-safe-tests.ts
@@ -1,7 +1,7 @@
import env = require("dotenv-safe")
import env = require('dotenv-safe');

env.config({
allowEmptyValues: true,
path: "/foo/bar/baz.env",
sample: "/foo/bar/qux.env"
})
allowEmptyValues: true,
path: '/foo/bar/baz.env',
sample: '/foo/bar/qux.env',
});
63 changes: 35 additions & 28 deletions types/dotenv-safe/index.d.ts
Expand Up @@ -4,43 +4,50 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2

import dotenv = require("dotenv")
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[]
/**
* 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,
/**
* 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): dotenv.DotenvConfigOutput
export function config(options?: DotenvSafeOptions): DotenvSafeConfigOutput;

0 comments on commit 404d5f0

Please sign in to comment.