chore(repo): consolidate local env and clean root files

This commit is contained in:
yoyuzh
2026-04-06 23:50:56 +08:00
parent ed837f5ec9
commit 3afebbb338
21 changed files with 200 additions and 5105 deletions

View File

@@ -299,3 +299,28 @@ export function parseSimpleEnv(rawText) {
return parsed;
}
export async function loadRepoEnv({
repoRoot,
candidateFileNames = ['.env.local', '.env', '.env.oss.local'],
}) {
for (const fileName of candidateFileNames) {
const filePath = path.join(repoRoot, fileName);
try {
const raw = await fs.readFile(filePath, 'utf-8');
const values = parseSimpleEnv(raw);
for (const [key, value] of Object.entries(values)) {
if (!process.env[key]) {
process.env[key] = value;
}
}
} catch (error) {
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
continue;
}
throw error;
}
}
}