don't crash the app on a bad .json

This commit is contained in:
Jack Amadeo
2026-04-03 10:33:34 -04:00
parent f6ebca3b76
commit 3ebe0f445d
+11 -5
View File
@@ -27,13 +27,19 @@ function findDistroDir(): string | null {
// Executes on import — must be imported before anything that reads process.env
distroDir = findDistroDir();
if (distroDir) {
const configPath = path.join(distroDir, 'distro.json');
distroConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
try {
const configPath = path.join(distroDir, 'distro.json');
distroConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
if (distroConfig.env) {
for (const [key, value] of Object.entries(distroConfig.env)) {
process.env[key] = value;
if (distroConfig.env) {
for (const [key, value] of Object.entries(distroConfig.env)) {
process.env[key] = value;
}
}
} catch (err) {
console.error('Failed to load distro.json, falling back to stock defaults:', err);
distroDir = null;
distroConfig = {};
}
}