Alex Mikhalev
6 years ago
19 changed files with 62 additions and 33 deletions
@ -1,9 +1,6 @@
@@ -1,9 +1,6 @@
|
||||
const fs = require("fs"); |
||||
const path = require("path"); |
||||
const paths = require("./paths"); |
||||
|
||||
// Make sure that including paths.js after env.js will read .env variables.
|
||||
delete require.cache[require.resolve("./paths")]; |
||||
const paths = require("../paths") |
||||
|
||||
const NODE_ENV = process.env.NODE_ENV; |
||||
if (!NODE_ENV) { |
@ -1,4 +1,5 @@
@@ -1,4 +1,5 @@
|
||||
import * as moduleAlias from "module-alias"; |
||||
import * as path from "path"; |
||||
moduleAlias.addAlias("@common", path.resolve(__dirname, "..", "common")); |
||||
moduleAlias.addAlias("@common", path.resolve(__dirname, "common")); |
||||
moduleAlias.addAlias("@server", __dirname); |
||||
moduleAlias.addAlias("paths", path.resolve(__dirname, "..", "paths")); |
||||
|
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
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, |
||||
}); |
||||
} |
||||
}); |
Loading…
Reference in new issue