Skip to content

Commit 35a098c

Browse files
committed
feat: display tree diff on --long
1 parent ec06f77 commit 35a098c

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

lib/utils/reify-output.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const reifyOutput = (npm, arb) => {
4343

4444
if (diff) {
4545
let diffTable
46-
if (npm.config.get('dry-run')) {
46+
if (npm.config.get('dry-run') || npm.config.get('long')) {
4747
diffTable = new Table({
4848
chars: {
4949
top: '',

tap-snapshots/test/lib/utils/reify-output.js.test.cjs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,16 @@ exports[`test/lib/utils/reify-output.js TAP packages changed message > {"added"
16331633
}
16341634
`
16351635

1636-
exports[`test/lib/utils/reify-output.js TAP prints dedupe difference > diff table 1`] = `
1636+
exports[`test/lib/utils/reify-output.js TAP prints dedupe difference on dry-run > diff table 1`] = `
1637+
1638+
change bar 1.0.0 -> 2.1.0
1639+
remove bar 1.0.0
1640+
add foo 1.0.0
1641+
1642+
removed 1 package, and changed 1 package in {TIME}
1643+
`
1644+
1645+
exports[`test/lib/utils/reify-output.js TAP prints dedupe difference on long > diff table 1`] = `
16371646
16381647
change bar 1.0.0 -> 2.1.0
16391648
remove bar 1.0.0

test/lib/utils/reify-output.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ t.test('added packages should be looked up within returned tree', async t => {
381381
})
382382
})
383383

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

409409
t.matchSnapshot(out, 'diff table')
410410
})
411+
412+
t.test('prints dedupe difference on long', async t => {
413+
const mock = {
414+
actualTree: {
415+
name: 'foo',
416+
inventory: {
417+
has: () => false,
418+
},
419+
},
420+
diff: {
421+
children: [
422+
{ action: 'ADD', ideal: { name: 'foo', package: { version: '1.0.0' } } },
423+
{ action: 'REMOVE', actual: { name: 'bar', package: { version: '1.0.0' } } },
424+
{
425+
action: 'CHANGE',
426+
actual: { name: 'bar', package: { version: '1.0.0' } },
427+
ideal: { package: { version: '2.1.0' } },
428+
},
429+
],
430+
},
431+
}
432+
433+
const out = await mockReify(t, mock, {
434+
long: true,
435+
})
436+
437+
t.matchSnapshot(out, 'diff table')
438+
})

0 commit comments

Comments
 (0)