Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Commit

Permalink
fix(index): Limit subject and body character width
Browse files Browse the repository at this point in the history
Limit the subject line to 50 characters and wrap the body at 72
characters. These changes try to adhere to rules of a great git commit
message.
  • Loading branch information
erictleung committed Jun 3, 2017
1 parent e97a047 commit 3ecdeca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const rightPad = require('right-pad');

const types = require('./types.json');

const maxLineWidth = 100;
const maxLineWidth = 50;
const bodyLineWidth = 72;
const divider = '\n\n';
const length = longest(Object.keys(types)).length + 1;
// rightPad should be replaced with String::padEnd when available (node 8?)
Expand All @@ -21,7 +22,7 @@ module.exports = {
prompter(cz, commit) {
console.log(dedent`
Line 1 will be cropped at ${maxLineWidth} characters.
All other lines will be wrapped after ${maxLineWidth} characters.
All other lines will be wrapped after ${bodyLineWidth} characters.
`);

// Let's ask some questions of the user
Expand Down Expand Up @@ -75,17 +76,18 @@ module.exports = {
trim: true,
newline: '\n',
indent: '',
width: maxLineWidth
width: bodyLineWidth
};

// parentheses are only needed when a scope is present
let scope = answers.scope.trim();
scope = scope ? '(' + answers.scope.trim() + ')' : '';

// Hard limit this subject line
const subject = answers.subject.trim().slice(0, maxLineWidth);
const head = `${answers.type}${scope}: ${subject}`;

// Wrap these lines at 100 characters
// Wrap these lines at 72 characters
const body = wrap(answers.body, wrapOptions);

// Apply breaking change prefix, removing it if already present
Expand Down

0 comments on commit 3ecdeca

Please sign in to comment.