@@ -43,43 +43,38 @@ var RE_YAML_DELIMITER = /^\s*---\s*$/;
4343*
4444* @private
4545* @param {Array<string> } lines - text lines to process
46- * @returns {Array<string> } text lines without YAML blocks and multiple empty lines
46+ * @returns {Array<string> } processed commit message lines
4747*/
4848function stripYamlBlocks ( lines ) {
4949 var previousLineEmpty ;
50- var trimmed ;
5150 var inYaml ;
5251 var out ;
5352 var i ;
5453
5554 previousLineEmpty = false ;
56- out = [ ] ;
5755 inYaml = false ;
58-
56+ out = [ ] ;
5957 for ( i = 0 ; i < lines . length ; i ++ ) {
6058 // Check for YAML delimiter (---) with optional whitespace:
6159 if ( RE_YAML_DELIMITER . test ( lines [ i ] ) ) {
6260 inYaml = ! inYaml ; // Toggle YAML block state
6361 continue ;
6462 }
65-
6663 // Only include lines that are not part of YAML blocks:
67- if ( ! inYaml ) {
68- trimmed = trim ( lines [ i ] ) ;
69-
70- if ( trimmed === '' ) {
71- // Only add an empty line if the previous line wasn't empty:
72- if ( ! previousLineEmpty && out . length > 0 ) {
73- previousLineEmpty = true ;
74- out . push ( '' ) ;
75- }
76- } else {
77- previousLineEmpty = false ;
78- out . push ( lines [ i ] ) ; // Preserve original line formatting
64+ if ( inYaml ) {
65+ continue ;
66+ }
67+ if ( trim ( lines [ i ] ) === '' ) {
68+ // Only add an empty line if the previous line wasn't empty:
69+ if ( ! previousLineEmpty && out . length > 0 ) {
70+ previousLineEmpty = true ;
71+ out . push ( '' ) ;
7972 }
73+ } else {
74+ previousLineEmpty = false ;
75+ out . push ( lines [ i ] ) ; // Preserve original line formatting
8076 }
8177 }
82-
8378 return out ;
8479}
8580
@@ -115,9 +110,8 @@ function formatBreakingChange( note ) {
115110 restLines = contentLines . slice ( 1 ) ;
116111 hash = trim ( note . hash ) ;
117112
118- // Construct output string - use a single string concatenation when possible
113+ // Construct output string:
119114 out = '- [`' + hash . substring ( 0 , 7 ) + '`](' + STDLIB_GITHUB_URL + '/' + hash + '): ' + firstLine ;
120-
121115 if ( restLines . length > 0 ) {
122116 out += '\n\n' ;
123117 out += ' - ' + restLines . join ( '\n ' ) ;
@@ -148,18 +142,18 @@ function isBreakingChange( note ) {
148142* @returns {string } list of breaking changes
149143*/
150144function breakingChanges ( commits ) {
151- var breakingChanges ;
145+ var changes ;
152146 var notes ;
153147 var out ;
154148
155149 notes = collectField ( commits , 'notes' ) ;
156- breakingChanges = filter ( notes , isBreakingChange ) ;
157- if ( breakingChanges . length === 0 ) {
150+ changes = filter ( notes , isBreakingChange ) ;
151+ if ( changes . length === 0 ) {
158152 return '' ;
159153 }
160154 out = sectionStart ( 'breaking-changes' ) ;
161155 out += heading ( 'BREAKING CHANGES' , 3 ) ;
162- out += map ( breakingChanges , formatBreakingChange ) . join ( '\n' ) ;
156+ out += map ( changes , formatBreakingChange ) . join ( '\n' ) ;
163157 out += sectionEnd ( 'breaking-changes' ) ;
164158 return out ;
165159}
0 commit comments