From f1669f2114520f4f93216561ce5bfccebb932487 Mon Sep 17 00:00:00 2001 From: rahuld109 Date: Thu, 18 Dec 2025 21:23:29 -0800 Subject: [PATCH] refactor: replace dotenv with native Node.js process.loadEnvFile - 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 --- bin/index.js | 10 ++++++++-- package.json | 1 - test/commands/cache.test.js | 9 +++++++-- test/commands/summary.test.js | 9 +++++++-- test/commands/verify.test.js | 9 +++++++-- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/bin/index.js b/bin/index.js index 6e0d37d9..50683dab 100755 --- a/bin/index.js +++ b/bin/index.js @@ -1,6 +1,12 @@ #!/usr/bin/env node -import dotenv from "dotenv"; -dotenv.config({ quiet: true }); + +// Load .env file if it exists (quiet - no error if missing) +try { + process.loadEnvFile(); +} +catch { + // .env file not found or not readable - ignore silently +} // Import Node.js Dependencies import path from "node:path"; diff --git a/package.json b/package.json index a91f6cb7..027eb476 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,6 @@ "@topcli/pretty-json": "^1.0.0", "@topcli/prompts": "^2.0.0", "@topcli/spinner": "^4.0.0", - "dotenv": "^17.0.0", "filenamify": "^7.0.0", "highlightjs-line-numbers.js": "^2.8.0", "ini": "^6.0.0", diff --git a/test/commands/cache.test.js b/test/commands/cache.test.js index 60f47b13..65e8e7b6 100644 --- a/test/commands/cache.test.js +++ b/test/commands/cache.test.js @@ -1,5 +1,10 @@ -import dotenv from "dotenv"; -dotenv.config({ quiet: true }); +// Load .env file if it exists (quiet - no error if missing) +try { + process.loadEnvFile(); +} +catch { + // .env file not found or not readable - ignore silently +} // Import Node.js Dependencies import fs from "node:fs"; diff --git a/test/commands/summary.test.js b/test/commands/summary.test.js index a46c41ec..150e92d6 100644 --- a/test/commands/summary.test.js +++ b/test/commands/summary.test.js @@ -1,5 +1,10 @@ -import dotenv from "dotenv"; -dotenv.config({ quiet: true }); +// Load .env file if it exists (quiet - no error if missing) +try { + process.loadEnvFile(); +} +catch { + // .env file not found or not readable - ignore silently +} // Import Node.js Dependencies import { fileURLToPath } from "node:url"; diff --git a/test/commands/verify.test.js b/test/commands/verify.test.js index 2ddfaf38..274d6670 100644 --- a/test/commands/verify.test.js +++ b/test/commands/verify.test.js @@ -1,5 +1,10 @@ -import dotenv from "dotenv"; -dotenv.config({ quiet: true }); +// Load .env file if it exists (quiet - no error if missing) +try { + process.loadEnvFile(); +} +catch { + // .env file not found or not readable - ignore silently +} // Import Node.js Dependencies import { fileURLToPath } from "node:url";