diff --git a/lib/parse-commit-type.js b/lib/parse-commit-type.js index 70bd20b..1960712 100644 --- a/lib/parse-commit-type.js +++ b/lib/parse-commit-type.js @@ -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}:`; }; diff --git a/lib/parse-commit-type.spec.js b/lib/parse-commit-type.spec.js index 69586b9..f4bc451 100644 --- a/lib/parse-commit-type.spec.js +++ b/lib/parse-commit-type.spec.js @@ -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(); }); diff --git a/lib/wisdom.js b/lib/wisdom.js index 833bf00..5ef5f6b 100644 --- a/lib/wisdom.js +++ b/lib/wisdom.js @@ -86,7 +86,7 @@ async function publish({version, info, emitter, dryRun, force}) { const cmd = rendy(Cmd, { version: nextVersion, - commitType: parseCommitType(info.commitType), + commitType: parseCommitType(info), branch: info.branch || 'master', });