diff --git a/lib/view.js b/lib/view.js index 0e93fe81ae808..b8c22cd6a1274 100644 --- a/lib/view.js +++ b/lib/view.js @@ -407,8 +407,8 @@ async function printData (data, name, opts) { // we may have partial lines printed. log.disableProgress() - // print directly to stdout to not unnecessarily add blank lines - console.log(msg.trim()) + // only log if there is something to log + if (msg !== '') console.log(msg.trim()) } function cleanup (data) { diff --git a/test/lib/view.js b/test/lib/view.js index bd4876e14c417..9053d1a6473c2 100644 --- a/test/lib/view.js +++ b/test/lib/view.js @@ -332,7 +332,7 @@ t.test('should log package info', t => { t.test('package with --json and no versions', t => { viewJson(['brown'], () => { - t.equals(logs, '\n', 'no info to display') + t.equals(logs, '', 'no info to display') t.end() }) }) @@ -446,7 +446,7 @@ t.test('should log info by field name', t => { t.test('unknown nested field ', t => { view(['yellow@1.0.0', 'dist.foobar'], () => { - t.equals(logs, '\n', 'no info to display') + t.equals(logs, '', 'no info to display') t.end() }) })