Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __tests__/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,18 @@ test("multi log & commit", () => {
expect(cc.formatLog(cc.formatLog(cc.formatLog(input)))).toBe(output)
}
})


test("lowercase scope that include numbers", () => {
const cc = new ConventionalCommits(new Devmoji(new Config()))
expect(cc.formatCommit("feat(jira-123): testing")).toBe(
"feat(jira-123): ✨ testing"
)
})

test("uppercase scope that include numbers", () => {
const cc = new ConventionalCommits(new Devmoji(new Config()))
expect(cc.formatCommit("feat(JIRA-123): testing")).toBe(
"feat(JIRA-123): ✨ testing"
)
})
4 changes: 3 additions & 1 deletion __tests__/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ test("should", async () => {
chore(release): 2.1.5 [skip ci]
docs: fixed config example
feat(TextInput): add new variant
chore(deps): update dependency rollup to v2 (#35)`
chore(deps): update dependency rollup to v2 (#35)
feat(JIRA-123): add new variant
feat(jira-123): add new variant
.split("\n")
.map((s) => s.trim())
for (const msg of valid) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Cli {
if (/^([rR]evert)/.test(text)) return []

const errors = []
const match = /^(?<type>:?[a-z-]+)(?:\((?<scope>[a-z-]+)\))?(!?):\s+(?<description>.*)/iu.exec(
const match = /^(?<type>:?[a-z-]+)(?:\((?<scope>[a-z-0-9]+)\))?(!?):\s+(?<description>.*)/iu.exec(
text
)
if (match) {
Expand Down
2 changes: 1 addition & 1 deletion src/conventional-commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Devmoji } from "./devmoji"
import chalk from "chalk"

export class ConventionalCommits {
regex = /(?<type>:?[a-z-]+)(?:\((?<scope>[a-z-]+)\))?(!?):\s*(?:(?<other>(?::[a-z-]+:\s*)+)\s*)?/gmu
regex = /(?<type>:?[a-z-]+)(?:\((?<scope>[a-z-0-9]+)\))?(!?):\s*(?:(?<other>(?::[a-z-]+:\s*)+)\s*)?/gmui
constructor(public devmoji: Devmoji) {}

formatCommit(text: string, color = false) {
Expand Down