Added check-env script.

This commit is contained in:
Mike Cao 2023-05-16 20:41:20 -07:00
parent c567eddff9
commit 19ac0fce36
2 changed files with 34 additions and 1 deletions

32
scripts/check-env.js Normal file
View file

@ -0,0 +1,32 @@
/* eslint-disable no-console */
require('dotenv').config();
function checkMissing(vars) {
const missing = vars.reduce((arr, key) => {
if (!process.env[key]) {
arr.push(key);
}
}, []);
if (missing.length) {
console.log(`The following environment variables are not defined:`);
for (const item of missing) {
console.log(' - ', item);
}
process.exit(1);
}
}
checkMissing(['DATABASE_URL']);
if (process.env.CLICKHOUSE_URL) {
checkMissing(['CA_CERT', 'CLIENT_CERT', 'CLIENT_KEY', 'KAFKA_BROKER', 'KAFKA_URL', 'REDIS_URL']);
}
if (process.env.CLOUD_MODE) {
checkMissing(['CLOUD_URL']);
}
if (process.env.ENABLE_BLOCKER) {
checkMissing(['REDIS_URL']);
}