Skip to content

Commit

Permalink
build: only parse .env if found
Browse files Browse the repository at this point in the history
  • Loading branch information
tronghn committed Nov 2, 2024
1 parent fcb8a6b commit cecf21e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ subprojects {
dependsOn("formatKotlin")
}

withType<JavaExec> {
environment = file("$rootDir/.env").readLines()
.filterNot { it.isEmpty() || it.startsWith("#") }
.associate {
withType<JavaExec>().named("run") {
environment = file("$rootDir/.env")
.takeIf { it.exists() }
?.readLines()
?.filterNot { it.isEmpty() || it.startsWith("#") }
?.associate {
val (key, value) = it.split("=")
key to value.trimQuotes()
}
} ?: emptyMap()
}
}

Expand Down

0 comments on commit cecf21e

Please sign in to comment.