@@ -210,23 +210,34 @@ export class Commander {
210210 let stagePadEnd = 5 ;
211211 stages . forEach ( s => stagePadEnd = Math . max ( s . length , stagePadEnd ) ) ;
212212
213+ const hasDescriptions = jobs . some ( j => j . description !== "" ) ;
214+
213215 let descriptionPadEnd = 11 ;
214- jobs . forEach ( j => descriptionPadEnd = Math . max ( j . description . length , descriptionPadEnd ) ) ;
216+ if ( hasDescriptions ) {
217+ jobs . forEach ( j => descriptionPadEnd = Math . max ( j . description . length , descriptionPadEnd ) ) ;
218+ }
215219
216220 const jobNamePad = parser . jobNamePad ;
217221
218222 if ( ! listAll ) {
219223 jobs = jobs . filter ( j => j . when !== "never" ) ;
220224 }
221225
222- writeStreams . stdout ( chalk `{grey ${ "name" . padEnd ( jobNamePad ) } ${ "description" . padEnd ( descriptionPadEnd ) } } ` ) ;
226+ if ( hasDescriptions ) {
227+ writeStreams . stdout ( chalk `{grey ${ "name" . padEnd ( jobNamePad ) } ${ "description" . padEnd ( descriptionPadEnd ) } } ` ) ;
228+ } else {
229+ writeStreams . stdout ( chalk `{grey ${ "name" . padEnd ( jobNamePad ) } } ` ) ;
230+ }
223231 writeStreams . stdout ( chalk `{grey ${ "stage" . padEnd ( stagePadEnd ) } ${ "when" . padEnd ( whenPadEnd ) } } ` ) ;
224232 writeStreams . stdout ( chalk `{grey allow_failure needs}\n` ) ;
225233
226234 const renderLine = ( job : Job ) => {
227235 const needs = job . needs ?. filter ( n => ! n . project && ! n . pipeline ) . map ( n => n . job ) ;
228236 const allowFailure = job . allowFailure ? "true " : "false " ;
229- let jobLine = chalk `{blueBright ${ job . name . padEnd ( jobNamePad ) } } ${ job . description . padEnd ( descriptionPadEnd ) } ` ;
237+ let jobLine = chalk `{blueBright ${ job . name . padEnd ( jobNamePad ) } } ` ;
238+ if ( hasDescriptions ) {
239+ jobLine += `${ job . description . padEnd ( descriptionPadEnd ) } ` ;
240+ }
230241 jobLine += chalk `{yellow ${ job . stage . padEnd ( stagePadEnd ) } } ${ job . when . padEnd ( whenPadEnd ) } ${ allowFailure . padEnd ( 11 ) } ` ;
231242 if ( needs ) {
232243 jobLine += chalk ` [{blueBright ${ needs } }]` ;
@@ -267,10 +278,23 @@ export class Commander {
267278 jobs = jobs . filter ( j => j . when !== "never" ) ;
268279 }
269280
270- writeStreams . stdout ( "name;description;stage;when;allowFailure;needs\n" ) ;
281+ const hasDescriptions = jobs . some ( j => j . description !== "" ) ;
282+
283+ const header = [ "name" , hasDescriptions ? "description" : null , "stage" , "when" , "allowFailure" , "needs" ] . filter ( Boolean ) . join ( ";" ) ;
284+ writeStreams . stdout ( `${ header } \n` ) ;
285+
271286 jobs . forEach ( ( job ) => {
272- const needs = job . needs ?. filter ( n => ! n . project && ! n . pipeline ) . map ( n => n . job ) . join ( "," ) ?? [ ] ;
273- writeStreams . stdout ( `${ job . name } ;"${ job . description } ";${ job . stage } ;${ job . when } ;${ job . allowFailure ? "true" : "false" } ;[${ needs } ]\n` ) ;
287+ const needs = job . needs === null ? "" : `[${ job . needs . filter ( n => ! n . project && ! n . pipeline ) . map ( n => n . job ) . join ( "," ) } ]` ;
288+ let allowFailure : string ;
289+ if ( typeof job . allowFailure === "object" ) {
290+ const codes = Array . isArray ( job . allowFailure . exit_codes ) ? job . allowFailure . exit_codes : [ job . allowFailure . exit_codes ] ;
291+ allowFailure = `[${ codes . join ( "," ) } ]` ;
292+ } else {
293+ allowFailure = job . allowFailure ? "true" : "false" ;
294+ }
295+
296+ const row = [ job . name , hasDescriptions ? `"${ job . description } "` : null , job . stage , job . when , allowFailure , needs ] . filter ( v => v !== null ) . join ( ";" ) ;
297+ writeStreams . stdout ( `${ row } \n` ) ;
274298 } ) ;
275299 }
276300
0 commit comments