umami/scripts/check-env.js

32 lines
678 B
JavaScript
Raw Normal View History

2023-05-17 05:41:20 +02:00
/* eslint-disable no-console */
require('dotenv').config();
function checkMissing(vars) {
const missing = vars.reduce((arr, key) => {
if (!process.env[key]) {
arr.push(key);
}
2023-05-17 05:46:15 +02:00
return arr;
2023-05-17 05:41:20 +02:00
}, []);
if (missing.length) {
console.log(`The following environment variables are not defined:`);
for (const item of missing) {
console.log(' - ', item);
}
process.exit(1);
}
}
2023-05-17 06:13:17 +02:00
if (!process.env.SKIP_DB_CHECK && !process.env.DATABASE_TYPE) {
checkMissing(['DATABASE_URL']);
}
2023-05-17 05:41:20 +02:00
if (process.env.CLICKHOUSE_URL) {
2024-04-17 09:10:02 +02:00
checkMissing(['KAFKA_BROKER', 'KAFKA_URL', 'REDIS_URL']);
2023-05-17 05:41:20 +02:00
}
if (process.env.CLOUD_MODE) {
checkMissing(['CLOUD_URL']);
}