Skip to content

Commit 9ce9be2

Browse files
committed
refactor: replace strip-ansi with native module
Inspired by eslint/eslint#18982 This API is built-in since node 16.11. react-native-cli already requires node 18 as of last year.
1 parent 9da12a4 commit 9ce9be2

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

packages/cli-doctor/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"node-stream-zip": "^1.9.1",
2222
"ora": "^5.4.1",
2323
"semver": "^7.5.2",
24-
"strip-ansi": "^5.2.0",
2524
"wcwidth": "^1.0.1",
2625
"yaml": "^2.2.1"
2726
},

packages/cli-doctor/src/tools/healthchecks/common.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import chalk from 'chalk';
22
import readline from 'readline';
33
import wcwidth from 'wcwidth';
4-
import stripAnsi from 'strip-ansi';
4+
import util from 'util';
55
import {logger} from '@react-native-community/cli-tools';
66
import {Loader} from '../../types';
77

@@ -94,7 +94,10 @@ const logError = ({
9494
function calculateMessageSize(message: string) {
9595
return Math.max(
9696
1,
97-
Math.ceil(wcwidth(stripAnsi(message)) / (process.stdout.columns || 80)),
97+
Math.ceil(
98+
wcwidth(util.stripVTControlCharacters(message)) /
99+
(process.stdout.columns || 80),
100+
),
98101
);
99102
}
100103

yarn.lock

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10755,16 +10755,7 @@ string-natural-compare@^3.0.1:
1075510755
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
1075610756
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==
1075710757

10758-
"string-width-cjs@npm:string-width@^4.2.0":
10759-
version "4.2.3"
10760-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
10761-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
10762-
dependencies:
10763-
emoji-regex "^8.0.0"
10764-
is-fullwidth-code-point "^3.0.0"
10765-
strip-ansi "^6.0.1"
10766-
10767-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
10758+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1076810759
version "4.2.3"
1076910760
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1077010761
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -10859,7 +10850,7 @@ string_decoder@~1.1.1:
1085910850
dependencies:
1086010851
safe-buffer "~5.1.0"
1086110852

10862-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
10853+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1086310854
version "6.0.1"
1086410855
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1086510856
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -10873,20 +10864,13 @@ strip-ansi@^4.0.0:
1087310864
dependencies:
1087410865
ansi-regex "^3.0.0"
1087510866

10876-
strip-ansi@^5.0.0, strip-ansi@^5.2.0:
10867+
strip-ansi@^5.0.0:
1087710868
version "5.2.0"
1087810869
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"
1087910870
integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==
1088010871
dependencies:
1088110872
ansi-regex "^4.1.0"
1088210873

10883-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
10884-
version "6.0.1"
10885-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
10886-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
10887-
dependencies:
10888-
ansi-regex "^5.0.1"
10889-
1089010874
strip-ansi@^7.0.1:
1089110875
version "7.0.1"
1089210876
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
@@ -11765,7 +11749,7 @@ wordwrap@^1.0.0:
1176511749
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
1176611750
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=
1176711751

11768-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
11752+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
1176911753
version "7.0.0"
1177011754
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1177111755
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -11783,15 +11767,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
1178311767
string-width "^4.1.0"
1178411768
strip-ansi "^6.0.0"
1178511769

11786-
wrap-ansi@^7.0.0:
11787-
version "7.0.0"
11788-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
11789-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
11790-
dependencies:
11791-
ansi-styles "^4.0.0"
11792-
string-width "^4.1.0"
11793-
strip-ansi "^6.0.0"
11794-
1179511770
wrap-ansi@^8.1.0:
1179611771
version "8.1.0"
1179711772
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)