Skip to content

Commit

Permalink
feature: commitType: read package-name
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Aug 15, 2023
1 parent 9d63909 commit 3cb9fa7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
11 changes: 5 additions & 6 deletions lib/parse-commit-type.js
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}:`;
};

21 changes: 13 additions & 8 deletions lib/parse-commit-type.spec.js
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();
});
2 changes: 1 addition & 1 deletion lib/wisdom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

Expand Down

0 comments on commit 3cb9fa7

Please sign in to comment.