Skip to content

Commit

Permalink
fix: Ensure \r chars do not break progress output
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Oct 2, 2023
1 parent 48bc757 commit 888af14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/private/cli-progress-footer/update-progress-props.js
Expand Up @@ -4,10 +4,12 @@ const d = require("d")
, strip = require("cli-color/strip")
, resolveLinesLength = require("./resolve-lines-length");

const newLineRe = /[\n\r]/u;

module.exports = {
updateProgress: d(function (progressRows) {
if (!Array.isArray(progressRows)) {
progressRows = progressRows ? progressRows.split("\n") : [];
progressRows = progressRows ? progressRows.split(newLineRe) : [];
}
if (this._isDisabled) {
this._disabledProgressRows = progressRows;
Expand Down
2 changes: 1 addition & 1 deletion test/_fixtures/test-write.js
Expand Up @@ -14,7 +14,7 @@ module.exports = cliProgressFooter => {
expectedOut += "sample 2\n";

cliProgressFooter.updateProgress(
`${ [1, 2, 3, 4].map(item => `# item ${ item }`).join("\n") }`
`${ [1, 2, 3, 4].map(item => `# item ${ item }`).join("\r") }`
);
expectedOut += `\n${ [1, 2, 3, 4].map(item => `# item ${ item }`).join("\n") }\n`;

Expand Down

0 comments on commit 888af14

Please sign in to comment.