Skip to content

feat: add options.outputStripAnsi #179

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ Default: `console.log`
- If a string, it specifies the path to a file to output to.
- If a function, it will call the function with the output as the first parameter

### `options.outputStripAnsi`

Type: `Boolean`<br>
Default: false

- If true, when produces a human readable output, output will clear color and style.

### `options.pluginNames`

Type: `Object`<br>
Expand Down
5 changes: 5 additions & 0 deletions output.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const MS_IN_MINUTE = 60000;
const MS_IN_SECOND = 1000;

const chalk = require("chalk");
const ansiRegex = require("ansi-regex");
const { fg, bg } = require("./colours");
const { groupBy, getAverages, getTotalActiveTime } = require("./utils");

Expand Down Expand Up @@ -118,6 +119,10 @@ module.exports.getHumanOutput = (outputObj, options = {}) => {

output += "\n\n";

if (options.outputStripAnsi === true) {
return output.replace(ansiRegex(), "");
}

return output;
};

Expand Down
112 changes: 100 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"write-good": "^1.0.2"
},
"dependencies": {
"chalk": "^4.1.0"
"chalk": "^4.1.0",
"ansi-regex": "5.0.0"
}
}