@@ -9,7 +9,7 @@ const fs = require('fs');
99const $ = require ( 'child_process' ) ;
1010const hostedGitInfo = require ( 'hosted-git-info' ) ;
1111const changelog = require ( './changelog' ) ;
12- const github = require ( './github ' ) ;
12+ const footer = require ( './footer ' ) ;
1313
1414const CHANGES_HEADING = '# Changes' ;
1515const DEFAULT_CHANGES_FILE = 'CHANGES.md' ;
@@ -30,15 +30,6 @@ function buildTag(options, version, pkg) {
3030 ) ;
3131}
3232
33- function buildFooter ( newline , author , homepage ) {
34- let footer = `${ newline } _Released` ;
35- if ( author ) {
36- footer += homepage ? ` by [${ author } ](${ homepage } )` : ` by ${ author } ` ;
37- }
38- const today = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
39- return `${ footer } on ${ today } ._${ newline } ` ;
40- }
41-
4233// Write the commit history to the changes file
4334exports . write = async function ( options = { } ) {
4435 const changes_file = options . changes_file || DEFAULT_CHANGES_FILE ;
@@ -103,44 +94,31 @@ exports.write = async function (options = {}) {
10394 pkg
10495 } ) ;
10596
106- function write ( ) {
107- // Do not allow version to be added twice
108- if ( exists ( previous , version ) ) {
109- console . error ( `Version ${ version } is already in ${ changes_file } \n` ) ;
110- if ( changes ) {
111- console . error ( '# Changes for next release:\n' ) ;
112- console . error ( changes ) ;
113- }
114- process . exit ( 1 ) ;
115- return null ;
116- }
97+ if ( options . footer ) {
98+ const foot = await footer . generate ( ) ;
99+ changes += `${ newline } ${ foot } ${ newline } ` ;
100+ }
117101
118- // Generate new changes
119- let next = `${ heading } ## ${ version } ${ newline } ${ newline } ${ changes } ` ;
120- const remain = previous . substring ( heading . length ) ;
121- if ( remain ) {
122- next += `${ newline } ${ remain } ` ;
102+ // Do not allow version to be added twice
103+ if ( exists ( previous , version ) ) {
104+ console . error ( `Version ${ version } is already in ${ changes_file } \n` ) ;
105+ if ( changes ) {
106+ console . error ( '# Changes for next release:\n' ) ;
107+ console . error ( changes ) ;
123108 }
124- fs . writeFileSync ( changes_file , next ) ;
125-
126- return { previous, changes_file } ;
109+ process . exit ( 1 ) ;
110+ return null ;
127111 }
128112
129- if ( options . footer ) {
130- const author = process . env . GIT_AUTHOR_NAME ;
131- if ( author ) {
132- const email = process . env . GIT_AUTHOR_EMAIL ;
133- if ( email ) {
134- const homepage = await github . fetchUserHomepage ( email ) ;
135- changes += buildFooter ( newline , author , homepage ) ;
136- return write ( ) ;
137- }
138- changes += buildFooter ( newline , author ) ;
139- } else {
140- changes += buildFooter ( newline ) ;
141- }
113+ // Generate new changes
114+ let next = `${ heading } ## ${ version } ${ newline } ${ newline } ${ changes } ` ;
115+ const remain = previous . substring ( heading . length ) ;
116+ if ( remain ) {
117+ next += `${ newline } ${ remain } ` ;
142118 }
143- return write ( ) ;
119+ fs . writeFileSync ( changes_file , next ) ;
120+
121+ return { previous, changes_file } ;
144122} ;
145123
146124// Roll back changes
0 commit comments