DefinitelyTyped/dotenv/dotenv-tests.ts
Eric Naeseth ba2209ad58 [dotenv] Add dotenv.parse(); add tslint.json and fix warnings (#13986)
* [dotenv] Add tslint.json and fix errors

* [dotenv] Add parse() function

* [dotenv] Add missing definition author
2017-01-13 11:53:46 -08:00

27 lines
602 B
TypeScript

import dotenv = require('dotenv');
// typically, result will be an Object
const env = dotenv.config({
silent: true
});
const dbUrl: string | null = !env ? null : env['DATABASE_URL'];
// ... but it might also be `false`
const result = dotenv.config({
path: '.non-existing-env'
});
dotenv.config({
path: '.env'
});
dotenv.config({
encoding: 'utf8'
});
const parsed = dotenv.parse("ENVIRONMENT=production\nDEBUG=no\n");
const debug: string = parsed['DEBUG'];
const parsedFromBuffer = dotenv.parse(new Buffer("JUSTICE=league\n"));
const justice: string = parsedFromBuffer['JUSTICE'];