From 9cf1b22eba74de167666bb11f9a5e3b58321cb6e Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Thu, 14 Mar 2019 11:28:57 -0700 Subject: [PATCH] Add typedefs for dotenv and dotenv-expand --- flow-libs/dotenv-expand.js.flow | 7 +++++++ flow-libs/dotenv.js.flow | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 flow-libs/dotenv-expand.js.flow create mode 100644 flow-libs/dotenv.js.flow diff --git a/flow-libs/dotenv-expand.js.flow b/flow-libs/dotenv-expand.js.flow new file mode 100644 index 00000000000..5a3a00004e6 --- /dev/null +++ b/flow-libs/dotenv-expand.js.flow @@ -0,0 +1,7 @@ +// @flow strict-local + +declare module 'dotenv-expand' { + import type {DotenvConfigOutput} from 'dotenv'; + + declare module.exports: (config: DotenvConfigOutput) => DotenvConfigOutput; +} diff --git a/flow-libs/dotenv.js.flow b/flow-libs/dotenv.js.flow new file mode 100644 index 00000000000..6975bf174d9 --- /dev/null +++ b/flow-libs/dotenv.js.flow @@ -0,0 +1,30 @@ +// @flow strict-local + +// Derived from and sections taken from +// https://github.com/motdotla/dotenv/blob/03a891554c49915fe919c649f51b3adcae662a84/lib/main.js +// and https://github.com/flow-typed/flow-typed/blob/9b8ade1b0dd93ae110a5612cce80d81d0c34a00e/definitions/npm/dotenv_v4.x.x/flow_v0.34.x-/dotenv_v4.x.x.js +// both of which are MIT licensed (see roots of their respective repos) +declare module 'dotenv' { + declare type DotenvParseOptions = {| + debug?: boolean + |}; + + // keys and values from src + declare type DotenvParseOutput = {[string]: string}; + + declare type DotenvConfigOptions = {| + path?: string, // path to .env file + encoding?: string, // encoding of .env file + debug?: string // turn on logging for debugging purposes + |}; + + declare type DotenvConfigOutput = {| + parsed?: DotenvParseOutput, + error?: Error + |}; + + declare module.exports: { + config(options: ?DotenvConfigOptions): DotenvConfigOutput, + parse(src: string | Buffer, options: ?DotenvParseOptions): DotenvParseOutput + }; +}