Skip to content

Commit

Permalink
Add typedefs for dotenv and dotenv-expand
Browse files Browse the repository at this point in the history
  • Loading branch information
wbinnssmith committed Mar 14, 2019
1 parent 8b8e900 commit 9cf1b22
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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;
}
30 changes: 30 additions & 0 deletions 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
};
}

0 comments on commit 9cf1b22

Please sign in to comment.