Documentation, screenshots and a couple of tweaks (#142)
* Documentation, screenshots and a couple of tweaks * Changelog * changelog
This commit is contained in:
1 parent
bea7fb209b
commit
0bcf361eb0
27 files changed
+642
-102
No files matched your search
@@ -4,12 +4,18 @@ const path = require('path');
|
||||
|
||||
const envFile = path.join(__dirname, '../.env');
|
||||
|
||||
function getEnvVars() {
|
||||
function getEnvVars(requiredVars = undefined) {
|
||||
let envVars = process.env;
|
||||
if (fs.existsSync(envFile)) {
|
||||
const envConfig = dotenv.parse(fs.readFileSync(envFile));
|
||||
envVars = { ...envVars, ...envConfig };
|
||||
}
|
||||
if (requiredVars) {
|
||||
const missingVars = requiredVars.filter((key) => !envVars[key]);
|
||||
if (missingVars.length) {
|
||||
throw new Error(`Missing environment variables: ${missingVars.join(', ')}`);
|
||||
}
|
||||
}
|
||||
|
||||
return envVars;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user