From cfd735d7d00f01e3772a35b541b1b141fd5a5c5c Mon Sep 17 00:00:00 2001 From: Simon Tran Date: Tue, 23 Jan 2024 17:31:56 -0500 Subject: [PATCH] fix: support array for path option --- lib/main.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/main.js b/lib/main.js index 7a009fc1..069f49c9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -209,7 +209,18 @@ function configDotenv (options) { if (options) { if (options.path != null) { - dotenvPath = _resolveHome(options.path) + let envPath = options.path + + if (Array.isArray(envPath)) { + for (const filepath of options.path) { + if (fs.existsSync(filepath)) { + envPath = filepath + break + } + } + } + + dotenvPath = _resolveHome(envPath) } if (options.encoding != null) { encoding = options.encoding