diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-21 21:17:41 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-21 21:17:41 +0200 |
commit | f25b818d9d41e2bb3969399cfc8bbff976b5aad7 (patch) | |
tree | 5f9137b374dfca42f596851c85116c9da181fa50 /sharedVariables/src/EnvFileReader.kt | |
download | ultra-notifier-f25b818d9d41e2bb3969399cfc8bbff976b5aad7.tar.gz ultra-notifier-f25b818d9d41e2bb3969399cfc8bbff976b5aad7.tar.bz2 ultra-notifier-f25b818d9d41e2bb3969399cfc8bbff976b5aad7.zip |
Init
Diffstat (limited to 'sharedVariables/src/EnvFileReader.kt')
-rw-r--r-- | sharedVariables/src/EnvFileReader.kt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sharedVariables/src/EnvFileReader.kt b/sharedVariables/src/EnvFileReader.kt new file mode 100644 index 0000000..95cbe39 --- /dev/null +++ b/sharedVariables/src/EnvFileReader.kt @@ -0,0 +1,15 @@ +package moe.nea.sharedbuild + + +import java.io.File + +fun parseEnvFile(file: File): Map<String, String> { + if (!file.exists()) return mapOf() + val map = mutableMapOf<String, String>() + for (line in file.readText().lines()) { + if (line.isEmpty() || line.startsWith("#")) continue + val parts = line.split("=", limit = 2) + map[parts[0]] = parts.getOrNull(1) ?: "" + } + return map +}
\ No newline at end of file |