Skip to content

Commit

Permalink
Improving pretty printing of extra items
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Walter committed Dec 1, 2021
1 parent 17771a8 commit db9afab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-camels-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@generates/roll": minor
---

Improving pretty printing of extra items
15 changes: 10 additions & 5 deletions packages/roll/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,30 @@ export const roll = {
...extra ? { data: mergeExtra(extra) } : {}
})
} else if (this.opts.pretty) {
let output = ' ' + message + '\n'
let output = ' ' + message
if (extra) {
let indentRequired
for (const item of extra) {
if (typeof item === 'string') {
output += ' ' + item + '\n'
output += indentRequired ? ' ' : ' '
output += item
indentRequired = false
} else if (typeof item === 'object') {
if (!indentRequired) output += '\n'
output += prettify(item) + '\n'
indentRequired = true
}
}
}
return output
return output + '\n'
}
let output = message.replace(nlRe, ' ')
if (extra) {
for (const item of extra) {
if (typeof item === 'string') {
output += item + ' '
output += ' ' + item
} else if (typeof item === 'object') {
output += stringify(item, undefined, '').replace(nlRe, ' ')
output += ' ' + stringify(item, undefined, '').replace(nlRe, ' ')
}
}
}
Expand Down

0 comments on commit db9afab

Please sign in to comment.