Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const reifyOutput = (npm, arb, extras = {}) => {
}

if (diff) {
const showDiff = npm.config.get('dry-run') || npm.config.get('long')
const showDiff = !npm.flatOptions.json &&
(npm.config.get('dry-run') || npm.config.get('long'))
const chalk = npm.chalk

depth({
Expand Down
47 changes: 47 additions & 0 deletions test/lib/utils/reify-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,53 @@ t.test('prints dedupe difference on dry-run', async t => {
t.matchSnapshot(out, 'diff table')
})

t.test('prints only json for dry-run and long', async t => {
for (const flag of ['dry-run', 'long']) {
await t.test(flag, async t => {
const out = await mockReify(t, {
actualTree: {
inventory: {
has: () => true,
},
children: [],
},
diff: {
children: [
{
action: 'ADD',
ideal: {
path: 'test/foo',
name: 'foo',
package: { version: '1.0.0' },
},
},
],
},
}, {
[flag]: true,
json: true,
})

t.strictSame(JSON.parse(out), {
add: [
{
name: 'foo',
version: '1.0.0',
path: 'test/foo',
},
],
added: 1,
audited: 0,
change: [],
changed: 0,
funding: 0,
remove: [],
removed: 0,
})
})
}
})

t.test('prints dedupe difference on long', async t => {
const mock = {
actualTree: {
Expand Down
Loading