description and source-codeprompter = function (cz, commit) {
console.log('\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n');
// Let's ask some questions of the user
// so that we can populate our commit
// template.
//
// See inquirer.js docs for specifics.
// You can also opt to use another input
// collection library if you prefer.
cz.prompt([
{
type: 'list',
name: 'type',
message: 'Select the type of change that you\'re committing:',
choices: choices
}, {
type: 'input',
name: 'scope',
message: 'Denote the scope of this change ($location, $browser, $compile, etc.):\n'
}, {
type: 'input',
name: 'subject',
message: 'Write a short, imperative tense description of the change:\n'
}, {
type: 'input',
name: 'body',
message: 'Provide a longer description of the change:\n'
}, {
type: 'input',
name: 'breaking',
message: 'List any breaking changes:\n'
}, {
type: 'input',
name: 'issues',
message: 'List any issues closed by this change:\n'
}
]).then(function(answers) {
var maxLineWidth = 100;
var wrapOptions = {
trim: true,
newline: '\n',
indent:'',
width: maxLineWidth
};
// parentheses are only needed when a scope is present
var scope = answers.scope.trim();
scope = scope ? '(' + answers.scope.trim() + ')' : '';
// Hard limit this line
var head = (answers.type + scope + ': ' + answers.subject.trim()).slice(0, maxLineWidth);
// Wrap these lines at 100 characters
var body = wrap(answers.body, wrapOptions);
// Apply breaking change prefix, removing it if already present
var breaking = answers.breaking.trim();
breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : '';
breaking = wrap(breaking, wrapOptions);
var issues = wrap(answers.issues, wrapOptions);
var footer = filter([ breaking, issues ]).join('\n\n');
commit(head + '\n\n' + body + '\n\n' + footer);
});
}