1+ const { stripVTControlCharacters } = require ( 'node:util' )
12const { Minipass } = require ( 'minipass' )
23const columnify = require ( 'columnify' )
34
@@ -15,8 +16,8 @@ const columnify = require('columnify')
1516// The returned stream will format this package data
1617// into a byte stream of formatted, displayable output.
1718
18- module . exports = async ( opts , clean ) => {
19- return opts . json ? new JSONOutputStream ( ) : new TextOutputStream ( opts , clean )
19+ module . exports = async ( opts ) => {
20+ return opts . json ? new JSONOutputStream ( ) : new TextOutputStream ( opts )
2021}
2122
2223class JSONOutputStream extends Minipass {
@@ -40,13 +41,11 @@ class JSONOutputStream extends Minipass {
4041}
4142
4243class TextOutputStream extends Minipass {
43- #clean
4444 #opts
4545 #line = 0
4646
47- constructor ( opts , clean ) {
47+ constructor ( opts ) {
4848 super ( )
49- this . #clean = clean
5049 this . #opts = opts
5150 }
5251
@@ -56,17 +55,17 @@ class TextOutputStream extends Minipass {
5655
5756 #prettify ( data ) {
5857 const pkg = {
59- author : data . maintainers . map ( ( m ) => `=${ this . #clean ( m . username ) } ` ) . join ( ' ' ) ,
58+ author : data . maintainers . map ( ( m ) => `=${ stripVTControlCharacters ( m . username ) } ` ) . join ( ' ' ) ,
6059 date : 'prehistoric' ,
61- description : this . #clean ( data . description ?? '' ) ,
60+ description : stripVTControlCharacters ( data . description ?? '' ) ,
6261 keywords : '' ,
63- name : this . #clean ( data . name ) ,
62+ name : stripVTControlCharacters ( data . name ) ,
6463 version : data . version ,
6564 }
6665 if ( Array . isArray ( data . keywords ) ) {
67- pkg . keywords = data . keywords . map ( ( k ) => this . #clean ( k ) ) . join ( ' ' )
66+ pkg . keywords = data . keywords . map ( ( k ) => stripVTControlCharacters ( k ) ) . join ( ' ' )
6867 } else if ( typeof data . keywords === 'string' ) {
69- pkg . keywords = this . #clean ( data . keywords . replace ( / [ , \s ] + / , ' ' ) )
68+ pkg . keywords = stripVTControlCharacters ( data . keywords . replace ( / [ , \s ] + / , ' ' ) )
7069 }
7170 if ( data . date ) {
7271 pkg . date = data . date . toISOString ( ) . split ( 'T' ) [ 0 ] // remove time
0 commit comments