@@ -15,6 +15,7 @@ const ms = require('ms')
15
15
const npmAuditReport = require ( 'npm-audit-report' )
16
16
const { readTree : getFundingInfo } = require ( 'libnpmfund' )
17
17
const auditError = require ( './audit-error.js' )
18
+ const Table = require ( 'cli-table3' )
18
19
19
20
// TODO: output JSON if flatOptions.json is true
20
21
const reifyOutput = ( npm , arb ) => {
@@ -104,31 +105,52 @@ const printAuditReport = (npm, report) => {
104
105
105
106
// print the diff tree of actions that would be taken
106
107
const 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
+ } )
108
132
109
133
for ( let i = 0 ; i < diff . children . length ; ++ i ) {
110
134
const child = diff . children [ i ]
111
- msg . push ( '\n' , child . action . toLowerCase ( ) , '\t' )
135
+ table [ i ] = [ child . action . toLowerCase ( ) ]
112
136
113
137
switch ( child . action ) {
114
138
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 )
116
140
break
117
141
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 )
119
143
break
120
144
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
126
148
)
127
149
break
128
150
}
129
151
}
130
152
131
- npm . output ( msg . join ( '' ) )
153
+ npm . output ( '\n' + table . toString ( ) )
132
154
}
133
155
134
156
const getAuditReport = ( npm , report ) => {
0 commit comments