@@ -18,6 +18,9 @@ const pkg = require('./package.json')
18
18
const debug = require ( 'debug' ) ( pkg . name )
19
19
const argv = require ( 'minimist' ) ( process . argv . slice ( 2 ) )
20
20
21
+ // Skip on formatting on Node.js 10.
22
+ const formatMarkdown = process . versions . node . startsWith ( '10.' ) ? false : import ( './format.mjs' )
23
+
21
24
const quiet = argv . quiet || argv . q
22
25
const help = argv . h || argv . help
23
26
const commitUrl = argv [ 'commit-url' ] || 'https://github.com/{ghUser}/{ghRepo}/commit/{ref}'
@@ -102,14 +105,13 @@ function organiseCommits (list) {
102
105
} )
103
106
}
104
107
105
- function printCommits ( list ) {
106
- let out = `${ list . join ( '\n' ) } \n`
107
-
108
- if ( ! process . stdout . isTTY ) {
109
- out = stripAnsi ( out )
108
+ async function printCommits ( list ) {
109
+ for await ( let commit of list ) {
110
+ if ( ! process . stdout . isTTY ) {
111
+ commit = stripAnsi ( commit )
112
+ }
113
+ process . stdout . write ( commit )
110
114
}
111
-
112
- process . stdout . write ( out )
113
115
}
114
116
115
117
function onCommitList ( err , list ) {
@@ -142,10 +144,20 @@ function onCommitList (err, list) {
142
144
formatted . push ( commitToOutput ( commit , formatType . PLAINTEXT , ghId , commitUrl ) )
143
145
}
144
146
145
- list = formatted
147
+ list = formatted . map ( ( line ) => ` ${ line } \n` )
146
148
} else {
147
- list = list . map ( ( commit ) => {
148
- return commitToOutput ( commit , format , ghId , commitUrl )
149
+ list = list . map ( async ( commit ) => {
150
+ let output = commitToOutput ( commit , format , ghId , commitUrl )
151
+ if ( format === formatType . MARKDOWN ) {
152
+ if ( ! process . stdout . isTTY ) {
153
+ output = stripAnsi ( output )
154
+ }
155
+ if ( process . versions . node . startsWith ( '10.' ) ) {
156
+ return `${ output } \n`
157
+ }
158
+ return formatMarkdown . then ( ( module ) => module . default ( output ) )
159
+ }
160
+ return `${ output } \n`
149
161
} )
150
162
}
151
163
0 commit comments