From a4dab1ff69c9c347fea5ab423fe23d2f0d3e68f9 Mon Sep 17 00:00:00 2001 From: Frederic Kneier Date: Thu, 16 May 2024 01:26:34 +0200 Subject: [PATCH] Modifies pipeline file write logic --- src/nativeMain/kotlin/gitversion/Pipeline.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nativeMain/kotlin/gitversion/Pipeline.kt b/src/nativeMain/kotlin/gitversion/Pipeline.kt index f9b15e8..bfc13c3 100644 --- a/src/nativeMain/kotlin/gitversion/Pipeline.kt +++ b/src/nativeMain/kotlin/gitversion/Pipeline.kt @@ -2,6 +2,7 @@ package gitversion import me.archinamon.fileio.File import me.archinamon.fileio.appendText +import me.archinamon.fileio.writeText object Pipeline { val modifiers = listOf( @@ -47,7 +48,14 @@ object Pipeline { ) private fun writeLinesToFile(file: String, lines: Collection) { - File(file).appendText(lines.joinToString(separator = "\n", postfix = "\n")) + val content = lines.joinToString(separator = "\n", postfix = "\n") + + File(file).apply { + when { + exists() -> appendText(content) + else -> writeText(content) + } + } }