Skip to content

Commit

Permalink
don't require .env to exist
Browse files Browse the repository at this point in the history
  • Loading branch information
odilitime committed Nov 20, 2024
1 parent a2e0954 commit 8962b65
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions packages/core/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,12 @@ export function loadEnvConfig(): Settings {
// Node.js environment: load from .env file
const envPath = findNearestEnvFile();

if (!envPath) {
throw new Error("No .env file found in current or parent directories.");
}

// Load the .env file
const result = config({ path: envPath });
// attempt to Load the .env file into process.env
const result = config(envPath ? { path: envPath } : {});

if (result.error) {
throw new Error(`Error loading .env file: ${result.error}`);
if (!result.error) {
console.log(`Loaded .env file from: ${envPath}`);
}

console.log(`Loaded .env file from: ${envPath}`);
return process.env as Settings;
}

Expand Down

0 comments on commit 8962b65

Please sign in to comment.