Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: motdotla/dotenv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.1.0
Choose a base ref
...
head repository: motdotla/dotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.2.0
Choose a head ref
  • 3 commits
  • 8 files changed
  • 3 contributors

Commits on Sep 24, 2019

  1. optimize dotenv.png (#424)

    undirectlookable authored and maxbeatty committed Sep 24, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    ba6b34d View commit details

Commits on Oct 16, 2019

  1. TypeScript types (#430)

    * chore(deps): upgrade devDeps
    
    * feat: add typescript types
    maxbeatty authored Oct 16, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    75986d3 View commit details
  2. chore(release): 8.2.0

    maxbeatty committed Oct 16, 2019

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    70425a9 View commit details
Showing with 863 additions and 566 deletions.
  1. +2 −0 CHANGELOG.md
  2. BIN dotenv.png
  3. +754 −561 package-lock.json
  4. +8 −5 package.json
  5. +59 −0 types/index.d.ts
  6. +19 −0 types/test.ts
  7. +15 −0 types/tsconfig.json
  8. +6 −0 types/tslint.json
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [8.2.0](https://github.com/motdotla/dotenv/compare/v8.1.0...v8.2.0) (2019-10-16)

## [8.1.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.1.0) (2019-08-18)


Binary file modified dotenv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,315 changes: 754 additions & 561 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "dotenv",
"version": "8.1.0",
"version": "8.2.0",
"description": "Loads environment variables from .env file",
"main": "lib/main.js",
"types": "types",
"scripts": {
"flow": "flow",
"dtslint": "dtslint types",
"lint": "standard",
"postlint": "standard-markdown",
"pretest": "npm run lint",
"pretest": "npm run lint && npm run dtslint",
"test": "tap tests/*.js --100",
"prerelease": "npm test",
"release": "standard-version"
@@ -29,12 +31,13 @@
"license": "BSD-2-Clause",
"devDependencies": {
"decache": "^4.5.1",
"flow-bin": "^0.105.2",
"sinon": "^7.4.1",
"dtslint": "^0.9.8",
"flow-bin": "^0.109.0",
"sinon": "^7.5.0",
"standard": "^13.1.0",
"standard-markdown": "^5.1.0",
"standard-version": "^7.0.0",
"tap": "^14.6.1"
"tap": "^14.7.0"
},
"dependencies": {},
"engines": {
59 changes: 59 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// TypeScript Version: 3.0
/// <reference types="node" />

export interface DotenvParseOptions {
/**
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
*/
debug?: boolean;
}

export interface DotenvParseOutput {
[name: string]: string;
}

/**
* Parses a string or buffer in the .env file format into an object.
*
* @param src - contents to be parsed
* @param options - additional options
* @returns an object with keys and values based on `src`
*/
export function parse(
src: string | Buffer,
options?: DotenvParseOptions
): DotenvParseOutput;

export interface DotenvConfigOptions {
/**
* You may specify a custom path if your file containing environment variables is located elsewhere.
*/
path?: string;

/**
* You may specify the encoding of your file containing environment variables.
*/
encoding?: string;

/**
* You may turn on logging to help debug why certain keys or values are not being set as you expect.
*/
debug?: boolean;
}

export interface DotenvConfigOutput {
error?: Error;
parsed?: DotenvParseOutput;
}

/**
* Loads `.env` file contents into {@link https://nodejs.org/api/process.html#process_process_env | `process.env`}.
* Example: 'KEY=value' becomes { parsed: { KEY: 'value' } }
*
* @param options - controls behavior
* @returns an object with a `parsed` key if successful or `error` key if an error occurred
*
*/
export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
/** @deprecated since v7.0.0 Use config instead. */
export const load: typeof config;
19 changes: 19 additions & 0 deletions types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { config, parse } from "dotenv";

const env = config();
const dbUrl: string | null =
env.error || !env.parsed ? null : env.parsed["BASIC"];

config({
path: ".env-example",
encoding: "utf8",
debug: true
});

const parsed = parse("NODE_ENV=production\nDB_HOST=a.b.c");
const dbHost: string = parsed["DB_HOST"];

const parsedFromBuffer = parse(new Buffer("JUSTICE=league\n"), {
debug: true
});
const justice: string = parsedFromBuffer["JUSTICE"];
15 changes: 15 additions & 0 deletions types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"noEmit": true,
"baseUrl": ".",
"paths": {
"dotenv": ["."]
}
}
}
6 changes: 6 additions & 0 deletions types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dtslint.json",
"rules": {
"strict-export-declare-modifiers": false
}
}