@@ -46,8 +46,6 @@ const ERRORS = {
4646 new Error ( `Couldn't find @author of ${ version } release :(` ) ,
4747 NO_VERSION_POLICY : version =>
4848 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` ) ,
5149 NO_CHANGELOG_FOUND : version =>
5250 new Error ( `Couldn't find matching changelog for ${ version } ` ) ,
5351 INVALID_STATUS_CODE : ( url , status ) =>
@@ -128,7 +126,7 @@ const fetchChangelog = version => {
128126 const matches = rxSection . exec ( data ) ;
129127
130128 return new Promise ( ( resolve , reject ) =>
131- matches . length && matches [ 1 ]
129+ matches && matches . length && matches [ 1 ]
132130 ? resolve ( matches [ 1 ] . trim ( ) )
133131 : reject ( ERRORS . NO_CHANGELOG_FOUND ( version ) )
134132 ) ;
@@ -137,22 +135,11 @@ const fetchChangelog = version => {
137135
138136const fetchChangelogBody = version => {
139137 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-
149138 const replaceAsteriskLists = str =>
150139 str . replace ( / ^ ( [ ] { 0 , 4 } ) ( \* ) / gm, '$1- ' ) ;
151140
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 ( ) ) )
156143 ) ;
157144 } ) ;
158145} ;
@@ -166,7 +153,7 @@ const fetchVersionPolicy = version => {
166153 const matches = rxPolicy . exec ( section ) ;
167154
168155 return new Promise ( ( resolve , reject ) =>
169- matches . length && matches [ 1 ]
156+ matches && matches . length && matches [ 1 ]
170157 ? resolve ( matches [ 1 ] )
171158 : reject ( ERRORS . NO_VERSION_POLICY ( version ) )
172159 ) ;
@@ -191,7 +178,7 @@ const findAuthorLogin = (version, section) => {
191178 const matches = rxReleaseAuthor . exec ( section ) ;
192179
193180 return new Promise ( ( resolve , reject ) =>
194- matches . length && matches [ 1 ]
181+ matches && matches . length && matches [ 1 ]
195182 ? resolve ( matches [ 1 ] )
196183 : reject ( ERRORS . RELEASE_EXISTS ( version ) )
197184 ) ;
0 commit comments