Skip to content

Commit

Permalink
Modifies pipeline file write logic
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic-kneier committed May 15, 2024
1 parent 4b3dd9e commit a4dab1f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/nativeMain/kotlin/gitversion/Pipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -47,7 +48,14 @@ object Pipeline {
)

private fun writeLinesToFile(file: String, lines: Collection<String>) {
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)
}
}
}


Expand Down

0 comments on commit a4dab1f

Please sign in to comment.