You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
645 B
25 lines
645 B
6 years ago
|
import * as fs from "fs";
|
||
|
|
||
|
// tslint:disable-next-line:no-var-requires
|
||
|
const paths = require("paths");
|
||
|
|
||
|
const NODE_ENV = process.env.NODE_ENV || "development";
|
||
|
|
||
|
const dotenvFiles: string[] = [
|
||
|
`${paths.dotenv}.${NODE_ENV}.local`,
|
||
|
`${paths.dotenv}.${NODE_ENV}`,
|
||
|
// Don"t include `.env.local` for `test` environment
|
||
|
// since normally you expect tests to produce the same
|
||
|
// results for everyone
|
||
|
NODE_ENV !== "test" && `${paths.dotenv}.local`,
|
||
|
paths.dotenv,
|
||
|
].filter(Boolean) as string[];
|
||
|
|
||
|
dotenvFiles.forEach((dotenvFile) => {
|
||
|
if (fs.existsSync(dotenvFile)) {
|
||
|
require("dotenv").config({
|
||
|
path: dotenvFile,
|
||
|
});
|
||
|
}
|
||
|
});
|