When working with environment variables for configuration: 1. **Reuse existing environment variables** rather than creating new ones. Leverage established variables like `NODE_TEST_CONTEXT` where possible to avoid fragmentation.
When working with environment variables for configuration:
Reuse existing environment variables rather than creating new ones. Leverage established variables like NODE_TEST_CONTEXT
where possible to avoid fragmentation.
Extract only necessary environment variables instead of passing the entire environment. This improves security and makes dependencies explicit.
// Avoid:
proxyEnv: process.env.NODE_USE_ENV_PROXY ? process.env : undefined,
// Prefer:
proxyEnv: process.env.NODE_USE_ENV_PROXY ? {
HTTP_PROXY: process.env.HTTP_PROXY,
HTTPS_PROXY: process.env.HTTPS_PROXY,
NO_PROXY: process.env.NO_PROXY
} : undefined,
Check environment variables consistently and be mindful of truthiness. Remember that environment variables are strings or undefined, and plan accordingly.
Document new environment variables if you absolutely must create them, and ensure they follow established naming conventions for your project.
Enter the URL of a public GitHub repository