-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix(rosetta): prints colors to log file #3953
Conversation
Rosetta error messages contain colors codes in the errors, which makes the errors produced by Rosetta look like garbage and very hard to parse. Strip the colors if we detect a non-TTY input. (Copied the regex from an MIT-licensed package to avoid adding extra dependencies)
const ANSI_PATTERN = new RegExp( | ||
[ | ||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', | ||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))', | ||
].join('|'), | ||
'g', | ||
); | ||
|
||
function stripColorCodes(x: string) { | ||
return x.replace(ANSI_PATTERN, ''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Copied the regex from an MIT-licensed package to avoid adding extra dependencies)
Still, it would not hurt to attribute to the original package/authors?
Added do-not-merge as I'd still like the attribution to be added... |
Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it! |
Merging (with squash)... |
Merging (with squash)... |
Rosetta error messages contain colors codes in the errors, which makes the errors produced by Rosetta look like garbage and very hard to parse. Strip the colors if we detect a non-TTY input. (Copied the regex from an MIT-licensed package to avoid adding extra dependencies) Port of aws/jsii#3953
Rosetta error messages contain colors codes in the errors, which makes the errors produced by Rosetta look like garbage and very hard to parse. Strip the colors if we detect a non-TTY input. (Copied the regex from an MIT-licensed package to avoid adding extra dependencies) Port of aws/jsii#3953 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Rosetta error messages contain colors codes in the errors, which makes the errors produced by Rosetta look like garbage and very hard to parse.
Strip the colors if we detect a non-TTY input.
(Copied the regex from an MIT-licensed package to avoid adding extra dependencies)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.