Project Browsers 1.0

This commit is contained in:
Jakub Zych
2026-03-07 23:51:53 +01:00
commit 3f4920a68f
31 changed files with 1433 additions and 0 deletions

30
lib/env-parser.js Normal file
View File

@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');
function parseEnvFile(filePath) {
const result = {};
if (!fs.existsSync(filePath)) return result;
const content = fs.readFileSync(filePath, 'utf8');
for (const line of content.split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const eqIndex = trimmed.indexOf('=');
if (eqIndex === -1) continue;
const key = trimmed.slice(0, eqIndex).trim();
let value = trimmed.slice(eqIndex + 1).trim();
// Strip surrounding quotes
if ((value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))) {
value = value.slice(1, -1);
}
result[key] = value;
}
return result;
}
module.exports = { parseEnvFile };