index.js
/**
 * Format the git commit message from given answers.
 *
 * @param {Object} answers Answers provide by `inquier.js`
 * @return {String} Formated git commit message
 */
Format the git commit message from given answers.
@param {Object} answers Answers provide by `inquier.js`
@return {String} Formated git commit message
Format the git commit message from given answers . @param { Object } answers Answers provide by ` inquier . js ` @return { String } Formated git commit message
function format(answers) {
  const scope = answers.scope || answers.package
    ? '(' +
      (answers.package ? answers.package.trim() + ':' : '') +
      (answers.scope ? answers.scope.trim() : '')
      + ') '
    : ''
  const head =
    (answers.breaking ? '[BREAKING] ' : '') +
    answers.type + ' ' +
    scope +
    truncate(answers.subject.trim(), 50)
  const body = wrap(answers.body, 72)
  const addFooter = answers.issues || answers.breaking
  const footer =
    (answers.issues ? 'Closes ' + answers.issues : '') +
    (answers.breaking ? 'Breaking Changes: ' + answers.breaking : '')
  return (head + '\n\n' + body + (addFooter ? '\n\n' + footer : ''))
}
function format ( answers ) { const scope = answers . scope || answers . package ? '(' + ( answers . package ? answers . package . trim ( ) + ':' : '' ) + ( answers . scope ? answers . scope . trim ( ) : '' ) + ') ' : '' const head = ( answers . breaking ? '[BREAKING] ' : '' ) + answers . type + ' ' + scope + truncate ( answers . subject . trim ( ) , 50 ) const body = wrap ( answers . body , 72 ) const addFooter = answers . issues || answers . breaking const footer = ( answers . issues ? 'Closes ' + answers . issues : '' ) + ( answers . breaking ? 'Breaking Changes: ' + answers . breaking : '' ) return ( head + '\n\n' + body + ( addFooter ? '\n\n' + footer : '' ) ) }
Format the git commit message from given answers.
Format the git commit message from given answers .
// parentheses are only needed when a scope is present // build head line and limit it to 50 (not including breaking prompt and such) // we hard limit to fifty to keep the rest of the commit line from not breaking 72 // i'm more experimenting w/fifty as a hard limit and realistically, we could go higher // but let's see how this goes // wrap body at 72