Skip to content

Commit

Permalink
fix: solve a problem with terminal colors in macOS. Closes #199
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Aug 25, 2023
1 parent 7fc9b2e commit e544840
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION as KOTLIN_VERSION

@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`java-gradle-plugin`
alias(libs.plugins.kotlin.jvm)
Expand Down Expand Up @@ -43,6 +42,7 @@ dependencies {
api(gradleKotlinDsl())
testImplementation(gradleTestKit())
testImplementation(libs.bundles.kotest)
implementation(libs.mordant)
}

tasks.withType<KotlinCompile> {
Expand Down Expand Up @@ -123,5 +123,5 @@ publishOnCentral {
}

detekt {
config = files("./detekt.yml")
config.setFrom("${rootDir.absolutePath}/detekt.yml")
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ detekt = "1.23.0"
[libraries]
kotest-junit = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
kotest-assertions-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest" }
mordant = { module = "com.github.ajalt.mordant:mordant", version = "2.1.0" }

[bundles]
kotest = ["kotest-junit", "kotest-assertions-jvm"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.nicolasfarabegoli.gradle

import com.github.ajalt.mordant.rendering.TextColors
import org.gradle.api.Project

/**
Expand Down Expand Up @@ -41,13 +42,13 @@ open class ConventionalCommitsExtension(private val project: Project) {
/**
* The message that will be shown if the commit is conventional commit compliant.
*/
var successMessage: String? = "\\e[32mCommit message meets Conventional Commit standards...\\e[0m"
var successMessage: String? = TextColors.green("Commit message meets Conventional Commit standards...")

/**
* The message that will be shown if the commit is not conventional commit compliant.
*/
var failureMessage: String? = """
\e[31mThe commit message does not meet the Conventional Commit standard\e[0m
${TextColors.red("The commit message does not meet the Conventional Commit standard")}
An example of a valid message is:
feat(login): add the 'remember me' button
More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConventionalCommitsTest : WordSpec({

projectDirectory.resolve(".git/hooks/commit-msg").exists() shouldBe true
projectDirectory.resolve(".git/hooks/commit-msg")
.readText() shouldContain "\\e[32mCommit message meets Conventional Commit standards...\\e[0m"
.readText() shouldContain "Commit message meets Conventional Commit standards..."
// Test if `'` character is correctly escaped into `\x27`
projectDirectory.resolve(".git/hooks/commit-msg")
.readText() shouldContain "feat(login): add the \\\\x27remember me\\\\x27 button"
Expand Down Expand Up @@ -168,7 +168,7 @@ class ConventionalCommitsTest : WordSpec({

projectDirectory.resolve(".git/hooks/commit-msg").exists() shouldBe true
projectDirectory.resolve(".git/hooks/commit-msg")
.readText() shouldContain "\\e[32mCommit message meets Conventional Commit standards...\\e[0m"
.readText() shouldContain "Commit message meets Conventional Commit standards..."
// Test if `'` character is correctly escaped into `\x27`
projectDirectory.resolve(".git/hooks/commit-msg")
.readText() shouldContain "feat(login): add the \\\\x27remember me\\\\x27 button"
Expand Down

0 comments on commit e544840

Please sign in to comment.