Skip to content

view: directly print to process.stdout #1791

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Closed
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
4 changes: 2 additions & 2 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down Expand Up @@ -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()
})
})
Expand Down