Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aefe4e4
commit e896b00
Showing
6 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
detekt-cli/src/main/kotlin/io/gitlab/arturbosch/detekt/cli/runners/VersionPrinter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.gitlab.arturbosch.detekt.cli.runners | ||
|
||
import io.gitlab.arturbosch.detekt.core.whichDetekt | ||
import java.io.PrintStream | ||
|
||
class VersionPrinter(private val outputPrinter: PrintStream) : Executable { | ||
|
||
override fun execute() { | ||
val version = whichDetekt() | ||
if (version != null) { | ||
outputPrinter.println(version) | ||
} else { | ||
throw IllegalStateException("Can't find the detekt version") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
detekt-cli/src/test/kotlin/io/gitlab/arturbosch/detekt/cli/runners/VersionPrinterSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.gitlab.arturbosch.detekt.cli.runners | ||
|
||
import io.gitlab.arturbosch.detekt.core.Detektor | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.spekframework.spek2.Spek | ||
import org.spekframework.spek2.style.specification.describe | ||
import java.io.ByteArrayOutputStream | ||
import java.io.PrintStream | ||
import java.nio.charset.Charset | ||
|
||
class VersionPrinterSpec : Spek({ | ||
|
||
describe("version printer") { | ||
|
||
it("print the version") { | ||
val byteArrayOutputStream = ByteArrayOutputStream() | ||
|
||
VersionPrinter(PrintStream(byteArrayOutputStream)).execute() | ||
|
||
assertThat(String(byteArrayOutputStream.toByteArray(), Charset.forName("UTF-8"))) | ||
.isEqualTo("1.6.0" + System.lineSeparator()) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
DetektVersion: 1.6.0 | ||
|