Skip to content

Commit

Permalink
fix: replace strip-ansi with stripVTControlCharacters (#2181)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #2177
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/TypeStat/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/TypeStat/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

`stripVTControlCharacters` was added in nodejs v16.11.0 and appears to
be a direct replacement for the functionality from `strip-ansi`.

`TypeStat` already declares a dependency on nodejs >= 18 in its
`package.json`, so depending on this new API should be safe.

Fixes #2177

---------

Co-authored-by: Loren Van Spronsen <lorenvs@google.com>
Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent 2a25af4 commit dae6659
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"commander": "13.1.0",
"enquirer": "2.4.1",
"glob": "11.0.1",
"strip-ansi": "7.1.0",
"ts-api-utils": "2.0.1"
},
"devDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/output/createProcessOutput.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from "node:fs";
import { EOL } from "os";
import stripAnsi from "strip-ansi";
import { stripVTControlCharacters } from "util";

import { ProcessOutput } from "./types.js";

Expand All @@ -11,7 +11,7 @@ export const createProcessOutput = (logFile?: string): ProcessOutput => {
return (line: string) => {
stream.write(line + EOL);
log?.(
stripAnsi(
stripVTControlCharacters(
`[${prefix}] ${line.replace(/^\r\n|\r|\n/g, "").replace(/\r\n|\r|\n$/g, "")}`,
),
);
Expand Down

0 comments on commit dae6659

Please sign in to comment.