1
+ const { stripVTControlCharacters } = require ( 'node:util' )
1
2
const { Minipass } = require ( 'minipass' )
2
3
const columnify = require ( 'columnify' )
3
4
@@ -15,8 +16,8 @@ const columnify = require('columnify')
15
16
// The returned stream will format this package data
16
17
// into a byte stream of formatted, displayable output.
17
18
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 )
20
21
}
21
22
22
23
class JSONOutputStream extends Minipass {
@@ -40,13 +41,11 @@ class JSONOutputStream extends Minipass {
40
41
}
41
42
42
43
class TextOutputStream extends Minipass {
43
- #clean
44
44
#opts
45
45
#line = 0
46
46
47
- constructor ( opts , clean ) {
47
+ constructor ( opts ) {
48
48
super ( )
49
- this . #clean = clean
50
49
this . #opts = opts
51
50
}
52
51
@@ -56,17 +55,17 @@ class TextOutputStream extends Minipass {
56
55
57
56
#prettify ( data ) {
58
57
const pkg = {
59
- author : data . maintainers . map ( ( m ) => `=${ this . #clean ( m . username ) } ` ) . join ( ' ' ) ,
58
+ author : data . maintainers . map ( ( m ) => `=${ stripVTControlCharacters ( m . username ) } ` ) . join ( ' ' ) ,
60
59
date : 'prehistoric' ,
61
- description : this . #clean ( data . description ?? '' ) ,
60
+ description : stripVTControlCharacters ( data . description ?? '' ) ,
62
61
keywords : '' ,
63
- name : this . #clean ( data . name ) ,
62
+ name : stripVTControlCharacters ( data . name ) ,
64
63
version : data . version ,
65
64
}
66
65
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 ( ' ' )
68
67
} else if ( typeof data . keywords === 'string' ) {
69
- pkg . keywords = this . #clean ( data . keywords . replace ( / [ , \s ] + / , ' ' ) )
68
+ pkg . keywords = stripVTControlCharacters ( data . keywords . replace ( / [ , \s ] + / , ' ' ) )
70
69
}
71
70
if ( data . date ) {
72
71
pkg . date = data . date . toISOString ( ) . split ( 'T' ) [ 0 ] // remove time
0 commit comments