@@ -15,6 +15,7 @@ const ms = require('ms')
1515const npmAuditReport = require ( 'npm-audit-report' )
1616const { readTree : getFundingInfo } = require ( 'libnpmfund' )
1717const auditError = require ( './audit-error.js' )
18+ const Table = require ( 'cli-table3' )
1819
1920// TODO: output JSON if flatOptions.json is true
2021const reifyOutput = ( npm , arb ) => {
@@ -104,31 +105,52 @@ const printAuditReport = (npm, report) => {
104105
105106// print the diff tree of actions that would be taken
106107const printDiff = ( npm , diff ) => {
107- const msg = [ ]
108+ const table = new Table ( {
109+ chars : {
110+ top : '' ,
111+ 'top-mid' : '' ,
112+ 'top-left' : '' ,
113+ 'top-right' : '' ,
114+ bottom : '' ,
115+ 'bottom-mid' : '' ,
116+ 'bottom-left' : '' ,
117+ 'bottom-right' : '' ,
118+ left : '' ,
119+ 'left-mid' : '' ,
120+ mid : '' ,
121+ 'mid-mid' : '' ,
122+ right : '' ,
123+ 'right-mid' : '' ,
124+ middle : ' ' ,
125+ } ,
126+ style : {
127+ 'padding-left' : 0 ,
128+ 'padding-right' : 0 ,
129+ border : 0 ,
130+ } ,
131+ } )
108132
109133 for ( let i = 0 ; i < diff . children . length ; ++ i ) {
110134 const child = diff . children [ i ]
111- msg . push ( '\n' , child . action . toLowerCase ( ) , '\t' )
135+ table [ i ] = [ child . action . toLowerCase ( ) ]
112136
113137 switch ( child . action ) {
114138 case 'ADD' :
115- msg . push ( [ child . ideal . name , child . ideal . package . version ] . join ( '\t' ) )
139+ table [ i ] . push ( child . ideal . name , child . ideal . package . version )
116140 break
117141 case 'REMOVE' :
118- msg . push ( [ child . actual . name , child . actual . package . version ] . join ( '\t' ) )
142+ table [ i ] . push ( child . actual . name , child . actual . package . version )
119143 break
120144 case 'CHANGE' :
121- msg . push (
122- [
123- child . actual . name ,
124- child . actual . package . version + ' -> ' + child . ideal . package . version ,
125- ] . join ( '\t' )
145+ table [ i ] . push (
146+ child . actual . name ,
147+ child . actual . package . version + ' -> ' + child . ideal . package . version
126148 )
127149 break
128150 }
129151 }
130152
131- npm . output ( msg . join ( '' ) )
153+ npm . output ( '\n' + table . toString ( ) )
132154}
133155
134156const getAuditReport = ( npm , report ) => {
0 commit comments