strip: delete stale docs/ and broccolini_bot_context.md
Both were saturated with references to removed features. Regenerate fresh post-MVP.
This commit is contained in:
27
config.js
27
config.js
@@ -3,31 +3,22 @@
|
||||
* Load dotenv so env is available when this module is required first.
|
||||
* dotenv-expand resolves ${NGROK_URL} etc. in .env.
|
||||
*
|
||||
* Test env: set ENV_FILE=.env.test to load .env.test instead of .env (see ENV_AND_SECURITY.md).
|
||||
* Never commit .env or .env.test; agents must not modify .env without explicit user confirmation.
|
||||
* Never commit .env; agents must not modify .env without explicit user confirmation.
|
||||
*/
|
||||
const path = require('path');
|
||||
const dotenv = require('dotenv');
|
||||
const dotenvExpand = require('dotenv-expand');
|
||||
|
||||
const envPath = process.env.ENV_FILE
|
||||
? path.resolve(process.cwd(), process.env.ENV_FILE)
|
||||
: undefined;
|
||||
let parsed = dotenv.config({ path: envPath, debug: process.env.NODE_ENV === 'development' });
|
||||
if (envPath && parsed.error) {
|
||||
console.warn(`[config] ENV_FILE=${process.env.ENV_FILE} not found or unreadable:`, parsed.error.message);
|
||||
}
|
||||
const parsed = dotenv.config({ debug: process.env.NODE_ENV === 'development' });
|
||||
dotenvExpand.expand(parsed);
|
||||
// If no ENV_FILE, also load repo root .env; only non-empty values override (so empty DISCORD_BOT_TOKEN= in root does not wipe app .env)
|
||||
if (!envPath) {
|
||||
const rootEnv = path.resolve(process.cwd(), '..', '.env');
|
||||
const rootParsed = dotenv.config({ path: rootEnv });
|
||||
if (!rootParsed.error && rootParsed.parsed) {
|
||||
for (const [k, v] of Object.entries(rootParsed.parsed)) {
|
||||
if (v != null && String(v).trim() !== '') process.env[k] = v;
|
||||
}
|
||||
dotenvExpand.expand(rootParsed);
|
||||
// Also load repo-root .env; only non-empty values override (so empty DISCORD_BOT_TOKEN= in root does not wipe app .env)
|
||||
const rootEnv = path.resolve(process.cwd(), '..', '.env');
|
||||
const rootParsed = dotenv.config({ path: rootEnv });
|
||||
if (!rootParsed.error && rootParsed.parsed) {
|
||||
for (const [k, v] of Object.entries(rootParsed.parsed)) {
|
||||
if (v != null && String(v).trim() !== '') process.env[k] = v;
|
||||
}
|
||||
dotenvExpand.expand(rootParsed);
|
||||
}
|
||||
|
||||
function toInt(v, fallback) {
|
||||
|
||||
Reference in New Issue
Block a user