A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/dffca29f0690be82692eaa44a1dd02a0807a70ae below:

print `--dry-run` diffs in table format (#7174) · npm/cli@dffca29 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+42

-27

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+42

-27

lines changed Original file line number Diff line number Diff line change

@@ -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) => {

Original file line number Diff line number Diff line change

@@ -1632,3 +1632,12 @@ exports[`test/lib/utils/reify-output.js TAP packages changed message > {"added"

1632 1632

}

1633 1633

}

1634 1634

`

1635 + 1636 +

exports[`test/lib/utils/reify-output.js TAP prints dedupe difference > diff table 1`] = `

1637 + 1638 +

add foo 1.0.0

1639 +

remove bar 1.0.0

1640 +

change bar 1.0.0 -> 2.1.0

1641 + 1642 +

removed 1 package, and changed 1 package in {TIME}

1643 +

`

Original file line number Diff line number Diff line change

@@ -406,21 +406,5 @@ t.test('prints dedupe difference', async t => {

406 406

'dry-run': true,

407 407

})

408 408 409 -

t.match(

410 -

out,

411 -

'add\tfoo\t1.0.0',

412 -

'should print added package'

413 -

)

414 - 415 -

t.match(

416 -

out,

417 -

'remove\tbar\t1.0.0',

418 -

'should print removed package'

419 -

)

420 - 421 -

t.match(

422 -

out,

423 -

'change\tbar\t1.0.0 -> 2.1.0',

424 -

'should print changed package'

425 -

)

409 +

t.matchSnapshot(out, 'diff table')

426 410

})

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4