Skip to content

Commit

Permalink
view: directly print to process.stdout
Browse files Browse the repository at this point in the history
Currently in npm 7 output of npm view is being printed
by a call to console.log which is causing an extra newline
on output compared to npm 6. Replace the call to console.log
with process.stdout.write to avoid this.

Fixes: npm#1639
  • Loading branch information
MylesBorins committed Sep 10, 2020
1 parent 1dbec09 commit 6cde6e7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ async function printData (data, name, opts) {
let msgJson = []
const includeVersions = versions.length > 1
let includeFields

versions.forEach(function (v) {
const fields = Object.keys(data[v])
includeFields = includeFields || (fields.length > 1)
Expand Down Expand Up @@ -412,7 +411,7 @@ async function printData (data, name, opts) {
log.disableProgress()

// print directly to stdout to not unnecessarily add blank lines
console.log(msg.trim())
process.stdout.write(msg.trim())
}

function cleanup (data) {
Expand Down

0 comments on commit 6cde6e7

Please sign in to comment.