in src/main/kotlin/org/jetbrains/changelog/tasks/GetChangelogTask.kt [123:148]
fun run() {
val content = with(changelog.get()) {
val version = projectVersion
when {
version != null -> get(version)
unreleased -> unreleasedItem ?: throw MissingVersionException(unreleasedTerm.get())
else -> releasedItems.firstOrNull() ?: throw MissingVersionException("any")
}
.withHeader(!noHeader)
.withSummary(!noSummary)
.withLinks(!noLinks)
.withLinkedHeader(!noLinks)
.withEmptySections(!noEmptySections)
.let { renderItem(it, Changelog.OutputType.MARKDOWN) }
}
// Write to file if specified or output to logger
outputFile.orNull?.let {
it.asFile.apply {
parentFile?.mkdirs()
writeText(content)
}
logger.lifecycle("Changelog written to: $path")
} ?: logger.quiet(content)
}