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) + } + } }