-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: commitType: read package-name
- Loading branch information
1 parent
9d63909
commit 3cb9fa7
Showing
3 changed files
with
19 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
export const PAREN = '(package)'; | ||
export const COLON = ': package:'; | ||
export const parseCommitType = (info) => { | ||
const {name = 'package', commitType = 'colon'} = info; | ||
|
||
export const parseCommitType = (type = 'colon') => { | ||
if (type === 'paren') | ||
return PAREN; | ||
if (commitType === 'paren') | ||
return `(${name})`; | ||
|
||
return COLON; | ||
return `: ${name}:`; | ||
}; | ||
|
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 |
---|---|---|
@@ -1,27 +1,32 @@ | ||
import {test} from 'supertape'; | ||
import { | ||
parseCommitType, | ||
PAREN, | ||
COLON, | ||
} from './parse-commit-type.js'; | ||
|
||
test('wisdom: parseCommitType: default', (t) => { | ||
const result = parseCommitType(); | ||
const result = parseCommitType({}); | ||
|
||
t.equal(result, COLON); | ||
t.equal(result, ': package:'); | ||
t.end(); | ||
}); | ||
|
||
test('wisdom: parseCommitType: paren', (t) => { | ||
const result = parseCommitType('paren'); | ||
const info = { | ||
commitType: 'paren', | ||
}; | ||
const result = parseCommitType(info); | ||
|
||
t.equal(result, PAREN); | ||
t.equal(result, '(package)'); | ||
t.end(); | ||
}); | ||
|
||
test('wisdom: parseCommitType: colon', (t) => { | ||
const result = parseCommitType('colon'); | ||
const info = { | ||
name: 'hello', | ||
commitType: 'colon', | ||
}; | ||
const result = parseCommitType(info); | ||
|
||
t.equal(result, COLON); | ||
t.equal(result, ': hello:'); | ||
t.end(); | ||
}); |
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