Skip to content

Commit 62f65a8

Browse files
authored
refactor: replace dotenv with native Node.js process.loadEnvFile (#638)
- Use process.loadEnvFile() instead of dotenv.config() - Wrap in try/catch to silently ignore missing .env files - Remove dotenv dependency from package.json Closes #636
1 parent 96af191 commit 62f65a8

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

bin/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env node
2-
import dotenv from "dotenv";
3-
dotenv.config({ quiet: true });
2+
3+
// Load .env file if it exists (quiet - no error if missing)
4+
try {
5+
process.loadEnvFile();
6+
}
7+
catch {
8+
// .env file not found or not readable - ignore silently
9+
}
410

511
// Import Node.js Dependencies
612
import path from "node:path";

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
"@topcli/pretty-json": "^1.0.0",
109109
"@topcli/prompts": "^2.0.0",
110110
"@topcli/spinner": "^4.0.0",
111-
"dotenv": "^17.0.0",
112111
"filenamify": "^7.0.0",
113112
"highlightjs-line-numbers.js": "^2.8.0",
114113
"ini": "^6.0.0",

test/commands/cache.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import dotenv from "dotenv";
2-
dotenv.config({ quiet: true });
1+
// Load .env file if it exists (quiet - no error if missing)
2+
try {
3+
process.loadEnvFile();
4+
}
5+
catch {
6+
// .env file not found or not readable - ignore silently
7+
}
38

49
// Import Node.js Dependencies
510
import fs from "node:fs";

test/commands/summary.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import dotenv from "dotenv";
2-
dotenv.config({ quiet: true });
1+
// Load .env file if it exists (quiet - no error if missing)
2+
try {
3+
process.loadEnvFile();
4+
}
5+
catch {
6+
// .env file not found or not readable - ignore silently
7+
}
38

49
// Import Node.js Dependencies
510
import { fileURLToPath } from "node:url";

test/commands/verify.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import dotenv from "dotenv";
2-
dotenv.config({ quiet: true });
1+
// Load .env file if it exists (quiet - no error if missing)
2+
try {
3+
process.loadEnvFile();
4+
}
5+
catch {
6+
// .env file not found or not readable - ignore silently
7+
}
38

49
// Import Node.js Dependencies
510
import { fileURLToPath } from "node:url";

0 commit comments

Comments
 (0)