From 87553efb41cff80d2e92af9690fdfd61cf824ead Mon Sep 17 00:00:00 2001 From: Ruurtjan Pul Date: Mon, 4 Apr 2022 13:19:32 +0200 Subject: [PATCH 1/2] #137 Add support for absolute paths --- src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala b/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala index fb2cf02..1f63cfe 100644 --- a/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala +++ b/src/main/scala/au/com/onegeek/sbtdotenv/SbtDotenv.scala @@ -84,9 +84,10 @@ object SbtDotenv extends AutoPlugin { fileName: String ): Option[Map[String, String]] = { val baseDirectory = state.configuration.baseDirectory + val filePath = if (fileName.startsWith("/")) fileName else s"${baseDirectory}/${fileName}" state.log.debug(s"Base directory: ${baseDirectory}") - state.log.debug(s"looking for .env file: ${baseDirectory}/${fileName}") - val dotEnvFile: File = new File(s"${baseDirectory}/${fileName}") + state.log.debug(s"looking for .env file: ${filePath}") + val dotEnvFile: File = new File(filePath) parseFile(dotEnvFile).map { environment => state.log.info( s".env detected (fileName=${fileName}). About to configure JVM System Environment with new map" From 0beda6b6f86863e421d994cee9c125433f8cef5e Mon Sep 17 00:00:00 2001 From: Ruurtjan Pul Date: Mon, 11 Apr 2022 15:35:24 +0200 Subject: [PATCH 2/2] Improve documentation: 'Change file name' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3a0d13..3c90e84 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ MY_CERT="-----BEGIN CERTIFICATE----- Variable expansion of the form `$FOO` and `${FOO}` is supported based on the values in `.env` or the system environment. ### Change file name -It is possible to change the file name `.env` +It is possible to override the default file name `.env`. It will be treated as an absolute path if it starts with a `/`, and as a relative path to base directory of this project otherwise. ``` ThisBuild / envFileName := "dotenv" ```