diff options
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 |