@realtimex/email-automator 2.3.4 → 2.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,16 +15,26 @@ function findPackageRoot(startDir: string): string {
15
15
  }
16
16
  current = dirname(current);
17
17
  }
18
- return process.cwd(); // Fallback
18
+ return process.cwd();
19
19
  }
20
20
 
21
- const packageRoot = findPackageRoot(__dirname);
22
-
23
- // 1. Try to load from current working directory (where npx is run)
24
- dotenv.config({ path: join(process.cwd(), '.env') });
21
+ function loadEnvironment() {
22
+ const cwdEnv = join(process.cwd(), '.env');
23
+ const rootEnv = join(findPackageRoot(__dirname), '.env');
24
+
25
+ if (existsSync(cwdEnv)) {
26
+ console.log(`📝 Loading environment from CWD: ${cwdEnv}`);
27
+ dotenv.config({ path: cwdEnv, override: true });
28
+ } else if (existsSync(rootEnv)) {
29
+ console.log(`📝 Loading environment from Root: ${rootEnv}`);
30
+ dotenv.config({ path: rootEnv, override: true });
31
+ } else {
32
+ // Just run default dotenv config in case it's in a standard location
33
+ dotenv.config();
34
+ }
35
+ }
25
36
 
26
- // 2. Fallback to package root
27
- dotenv.config({ path: join(packageRoot, '.env') });
37
+ loadEnvironment();
28
38
 
29
39
  function parseArgs(args: string[]): { port: number | null, noUi: boolean } {
30
40
  const portIndex = args.indexOf('--port');
@@ -13,13 +13,25 @@ function findPackageRoot(startDir) {
13
13
  }
14
14
  current = dirname(current);
15
15
  }
16
- return process.cwd(); // Fallback
16
+ return process.cwd();
17
17
  }
18
- const packageRoot = findPackageRoot(__dirname);
19
- // 1. Try to load from current working directory (where npx is run)
20
- dotenv.config({ path: join(process.cwd(), '.env') });
21
- // 2. Fallback to package root
22
- dotenv.config({ path: join(packageRoot, '.env') });
18
+ function loadEnvironment() {
19
+ const cwdEnv = join(process.cwd(), '.env');
20
+ const rootEnv = join(findPackageRoot(__dirname), '.env');
21
+ if (existsSync(cwdEnv)) {
22
+ console.log(`📝 Loading environment from CWD: ${cwdEnv}`);
23
+ dotenv.config({ path: cwdEnv, override: true });
24
+ }
25
+ else if (existsSync(rootEnv)) {
26
+ console.log(`📝 Loading environment from Root: ${rootEnv}`);
27
+ dotenv.config({ path: rootEnv, override: true });
28
+ }
29
+ else {
30
+ // Just run default dotenv config in case it's in a standard location
31
+ dotenv.config();
32
+ }
33
+ }
34
+ loadEnvironment();
23
35
  function parseArgs(args) {
24
36
  const portIndex = args.indexOf('--port');
25
37
  let port = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realtimex/email-automator",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "type": "module",
5
5
  "main": "dist/api/server.js",
6
6
  "bin": {