@@ -15,7 +15,7 @@ const {
1515 listBuilds, FailureAggregator, jobCache
1616} = require ( '../lib/ci/ci_result_parser' ) ;
1717const clipboardy = require ( 'clipboardy' ) ;
18- const { writeJson } = require ( '../lib/file' ) ;
18+ const { writeJson, writeFile } = require ( '../lib/file' ) ;
1919
2020const { runPromise } = require ( '../lib/run' ) ;
2121const auth = require ( '../lib/auth' ) ;
@@ -119,6 +119,10 @@ const argv = yargs
119119 type : 'string' ,
120120 describe : 'Write the results as json to the path'
121121 } )
122+ . option ( 'markdown' , {
123+ type : 'string' ,
124+ describe : 'Write the results as markdown to the path'
125+ } )
122126 . help ( )
123127 . argv ;
124128
@@ -142,8 +146,8 @@ async function getResults(cli, request, job) {
142146}
143147
144148async function runQueue ( queue , cli , request , argv ) {
145- let dataToCopy = '' ;
146- let dataToJson = [ ] ;
149+ let json = [ ] ;
150+ let markdown = '' ;
147151
148152 for ( let i = 0 ; i < queue . length ; ++ i ) {
149153 const job = queue [ i ] ;
@@ -158,16 +162,15 @@ async function runQueue(queue, cli, request, argv) {
158162 const build = await getResults ( cli , request , job ) ;
159163 build . display ( ) ;
160164
161- if ( argv . copy ) {
162- dataToCopy += build . formatAsMarkdown ( ) ;
165+ json = json . concat ( build . formatAsJson ( ) ) ;
166+ if ( ( argv . copy || argv . markdown ) && ! argv . stats ) {
167+ markdown += build . formatAsMarkdown ( ) ;
163168 }
164-
165- dataToJson = dataToJson . concat ( build . formatAsJson ( ) ) ;
166169 }
167170
168171 return {
169- json : dataToJson ,
170- copy : dataToCopy
172+ json,
173+ markdown
171174 } ;
172175}
173176
@@ -262,17 +265,24 @@ async function main(command, argv) {
262265 cli . separator ( 'Stats' ) ;
263266 cli . log ( '' ) ;
264267 aggregator . display ( ) ;
265- if ( argv . copy ) {
266- data . copy = aggregator . formatAsMarkdown ( ) ;
268+
269+ if ( argv . markdown || argv . copy ) {
270+ data . markdown = aggregator . formatAsMarkdown ( ) ;
267271 }
268272 }
269273
270274 if ( argv . copy ) {
271- clipboardy . writeSync ( data . copy ) ;
275+ clipboardy . writeSync ( data . markdown ) ;
272276 cli . separator ( '' ) ;
273277 cli . log ( `Written markdown to clipboard` ) ;
274278 }
275279
280+ if ( argv . markdown ) {
281+ writeFile ( argv . markdown , data . markdown ) ;
282+ cli . separator ( '' ) ;
283+ cli . log ( `Written markdown to ${ argv . markdown } ` ) ;
284+ }
285+
276286 if ( argv . json ) {
277287 writeJson ( argv . json , data . json ) ;
278288 cli . separator ( '' ) ;
0 commit comments