Skip to content

Commit

Permalink
feat: display tree diff on --long
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jan 24, 2024
1 parent ec06f77 commit 35a098c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const reifyOutput = (npm, arb) => {

if (diff) {
let diffTable
if (npm.config.get('dry-run')) {
if (npm.config.get('dry-run') || npm.config.get('long')) {
diffTable = new Table({
chars: {
top: '',
Expand Down
11 changes: 10 additions & 1 deletion tap-snapshots/test/lib/utils/reify-output.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,16 @@ exports[`test/lib/utils/reify-output.js TAP packages changed message > {"added"
}
`

exports[`test/lib/utils/reify-output.js TAP prints dedupe difference > diff table 1`] = `
exports[`test/lib/utils/reify-output.js TAP prints dedupe difference on dry-run > diff table 1`] = `
change bar 1.0.0 -> 2.1.0
remove bar 1.0.0
add foo 1.0.0
removed 1 package, and changed 1 package in {TIME}
`

exports[`test/lib/utils/reify-output.js TAP prints dedupe difference on long > diff table 1`] = `
change bar 1.0.0 -> 2.1.0
remove bar 1.0.0
Expand Down
30 changes: 29 additions & 1 deletion test/lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ t.test('added packages should be looked up within returned tree', async t => {
})
})

t.test('prints dedupe difference', async t => {
t.test('prints dedupe difference on dry-run', async t => {
const mock = {
actualTree: {
name: 'foo',
Expand All @@ -408,3 +408,31 @@ t.test('prints dedupe difference', async t => {

t.matchSnapshot(out, 'diff table')
})

t.test('prints dedupe difference on long', async t => {
const mock = {
actualTree: {
name: 'foo',
inventory: {
has: () => false,
},
},
diff: {
children: [
{ action: 'ADD', ideal: { name: 'foo', package: { version: '1.0.0' } } },
{ action: 'REMOVE', actual: { name: 'bar', package: { version: '1.0.0' } } },
{
action: 'CHANGE',
actual: { name: 'bar', package: { version: '1.0.0' } },
ideal: { package: { version: '2.1.0' } },
},
],
},
}

const out = await mockReify(t, mock, {
long: true,
})

t.matchSnapshot(out, 'diff table')
})

0 comments on commit 35a098c

Please sign in to comment.