mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* [dotenv] Add tslint.json and fix errors * [dotenv] Add parse() function * [dotenv] Add missing definition author
27 lines
602 B
TypeScript
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'];
|