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