Skip to content

Commit

Permalink
Remove trimmming
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Aug 29, 2021
1 parent 56cd3f8 commit dc299b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/report/finalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const hasContent = function ({ content }) {
return typeof content === 'string' && content.trim() !== ''
}

// Handle content returned by `reporter.report()`
// Handle content returned by `reporter.report()`.
// We purposely do not remove empty lines before/after the `content` since those
// might be used to avoid vertical jitter when the reporter knows those empty
// lines will be eventually filled (e.g. when combinations stats become
// available).
const handleContent = function ({
content,
output,
Expand All @@ -26,8 +30,7 @@ const handleContent = function ({
const contentA = trimEnd(content)
const contentB = wrapRows(contentA)
const contentC = handleColors(contentB, colors)
const contentD = trimContent(contentC)
return { content: contentD, output, format, footerString }
return { content: contentC, output, format, footerString }
}

// Trim the end of each line to avoid wrapping-related visual bugs
Expand All @@ -44,11 +47,3 @@ const trimEndLine = function (line) {
const handleColors = function (content, colors) {
return colors ? content : stripAnsi(content)
}

// Ensure that exactly one newline is before and after the content
const trimContent = function (content) {
const contentA = content.replace(NEWLINE_REGEXP, '')
return `${contentA}\n`
}

const NEWLINE_REGEXP = /(^\n*)|(\n*$)/gu
2 changes: 1 addition & 1 deletion src/report/formats/all/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const TERMINAL_FORMAT = {
},
concat: true,
footer(footer) {
return `\n${prettifyValue(footer)}\n`
return `\n\n${prettifyValue(footer)}\n`
},
padding: true,
}
9 changes: 8 additions & 1 deletion src/report/join.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import stripFinalNewline from 'strip-final-newline'

import { groupBy } from '../utils/group.js'

import { FORMATS } from './formats/list.js'
Expand Down Expand Up @@ -26,5 +28,10 @@ const getContentProperty = function ({ content }) {
const CONTENTS_DELIMITER = '\n'

const padContents = function (joinedContents, format) {
return FORMATS[format].padding ? addPadding(joinedContents) : joinedContents
if (FORMATS[format].padding === undefined) {
return joinedContents
}

const joinedContentsA = `${stripFinalNewline(joinedContents)}\n`
return addPadding(joinedContentsA)
}

0 comments on commit dc299b6

Please sign in to comment.