@@ -46,8 +46,6 @@ const ERRORS = {
46
46
new Error ( `Couldn't find @author of ${ version } release :(` ) ,
47
47
NO_VERSION_POLICY : version =>
48
48
new Error ( `Could not find version policy of ${ version } in its changelog` ) ,
49
- NO_CHANGELOG_BODY : version =>
50
- new Error ( `Could not find changelog body of ${ version } release` ) ,
51
49
NO_CHANGELOG_FOUND : version =>
52
50
new Error ( `Couldn't find matching changelog for ${ version } ` ) ,
53
51
INVALID_STATUS_CODE : ( url , status ) =>
@@ -128,7 +126,7 @@ const fetchChangelog = version => {
128
126
const matches = rxSection . exec ( data ) ;
129
127
130
128
return new Promise ( ( resolve , reject ) =>
131
- matches . length && matches [ 1 ]
129
+ matches && matches . length && matches [ 1 ]
132
130
? resolve ( matches [ 1 ] . trim ( ) )
133
131
: reject ( ERRORS . NO_CHANGELOG_FOUND ( version ) )
134
132
) ;
@@ -137,22 +135,11 @@ const fetchChangelog = version => {
137
135
138
136
const fetchChangelogBody = version => {
139
137
return fetchChangelog ( version ) . then ( section => {
140
- const rxSectionBody = / ( # # # N o t a b l e [ \s \S ] * ) / ;
141
- const rxFallbackSectionBody = / ( # # # C o m m i t [ \s \S ] * ) / ;
142
-
143
- // In case there's not a notable changes section for that release, nothing
144
- // will have matched so we fallback to reading the commits section instead
145
- const matches = rxSectionBody . test ( section )
146
- ? rxSectionBody . exec ( section )
147
- : rxFallbackSectionBody . exec ( section ) ;
148
-
149
138
const replaceAsteriskLists = str =>
150
139
str . replace ( / ^ ( [ ] { 0 , 4 } ) ( \* ) / gm, '$1- ' ) ;
151
140
152
- return new Promise ( ( resolve , reject ) =>
153
- matches . length && matches [ 1 ]
154
- ? resolve ( replaceAsteriskLists ( matches [ 1 ] . trim ( ) ) )
155
- : reject ( ERRORS . NO_CHANGELOG_BODY ( version ) )
141
+ return new Promise ( resolve =>
142
+ resolve ( replaceAsteriskLists ( section . trim ( ) ) )
156
143
) ;
157
144
} ) ;
158
145
} ;
@@ -166,7 +153,7 @@ const fetchVersionPolicy = version => {
166
153
const matches = rxPolicy . exec ( section ) ;
167
154
168
155
return new Promise ( ( resolve , reject ) =>
169
- matches . length && matches [ 1 ]
156
+ matches && matches . length && matches [ 1 ]
170
157
? resolve ( matches [ 1 ] )
171
158
: reject ( ERRORS . NO_VERSION_POLICY ( version ) )
172
159
) ;
@@ -191,7 +178,7 @@ const findAuthorLogin = (version, section) => {
191
178
const matches = rxReleaseAuthor . exec ( section ) ;
192
179
193
180
return new Promise ( ( resolve , reject ) =>
194
- matches . length && matches [ 1 ]
181
+ matches && matches . length && matches [ 1 ]
195
182
? resolve ( matches [ 1 ] )
196
183
: reject ( ERRORS . RELEASE_EXISTS ( version ) )
197
184
) ;
0 commit comments