@@ -31,7 +31,6 @@ export class PackJob {
31
31
32
32
import { Minipass } from 'minipass'
33
33
import * as zlib from 'minizlib'
34
- //@ts -ignore
35
34
import { Yallist } from 'yallist'
36
35
import { ReadEntry } from './read-entry.js'
37
36
import {
@@ -68,7 +67,7 @@ import { normalizeWindowsPath } from './normalize-windows-path.js'
68
67
import { TarOptions } from './options.js'
69
68
70
69
export class Pack
71
- extends Minipass < Minipass . ContiguousData , Buffer , WarnEvent >
70
+ extends Minipass < Buffer , ReadEntry | string , WarnEvent < Buffer > >
72
71
implements Warner
73
72
{
74
73
opt : TarOptions
@@ -99,6 +98,7 @@ export class Pack
99
98
[ ENDED ] : boolean = false
100
99
101
100
constructor ( opt : TarOptions = { } ) {
101
+ //@ts -ignore
102
102
super ( )
103
103
this . opt = opt
104
104
this . file = opt . file || ''
@@ -142,7 +142,7 @@ export class Pack
142
142
/* c8 ignore next */
143
143
if ( ! this . zip ) throw new Error ( 'impossible' )
144
144
const zip = this . zip
145
- zip . on ( 'data' , chunk => super . write ( chunk ) )
145
+ zip . on ( 'data' , chunk => super . write ( chunk as unknown as string ) )
146
146
zip . on ( 'end' , ( ) => super . end ( ) )
147
147
zip . on ( 'drain' , ( ) => this [ ONDRAIN ] ( ) )
148
148
this . on ( 'resume' , ( ) => zip . resume ( ) )
@@ -166,25 +166,46 @@ export class Pack
166
166
}
167
167
168
168
[ WRITE ] ( chunk : Buffer ) {
169
- return super . write ( chunk )
169
+ return super . write ( chunk as unknown as string )
170
170
}
171
171
172
172
add ( path : string | ReadEntry ) {
173
173
this . write ( path )
174
174
return this
175
175
}
176
176
177
- //@ts -ignore
178
- end ( path ?: string | ReadEntry ) {
177
+ end ( cb ?: ( ) => void ) : this
178
+ end ( path : string | ReadEntry , cb ?: ( ) => void ) : this
179
+ end (
180
+ path : string | ReadEntry ,
181
+ encoding ?: Minipass . Encoding ,
182
+ cb ?: ( ) => void ,
183
+ ) : this
184
+ end (
185
+ path ?: string | ReadEntry | ( ( ) => void ) ,
186
+ encoding ?: Minipass . Encoding | ( ( ) => void ) ,
187
+ cb ?: ( ) => void ,
188
+ ) {
189
+ /* c8 ignore start */
190
+ if ( typeof path === 'function' ) {
191
+ cb = path
192
+ path = undefined
193
+ }
194
+ if ( typeof encoding === 'function' ) {
195
+ cb = encoding
196
+ encoding = undefined
197
+ }
198
+ /* c8 ignore stop */
179
199
if ( path ) {
180
200
this . add ( path )
181
201
}
182
202
this [ ENDED ] = true
183
203
this [ PROCESS ] ( )
204
+ /* c8 ignore next */
205
+ if ( cb ) cb ( )
184
206
return this
185
207
}
186
208
187
- //@ts -ignore
188
209
write ( path : string | ReadEntry ) {
189
210
if ( this [ ENDED ] ) {
190
211
throw new Error ( 'write after end' )
@@ -293,7 +314,7 @@ export class Pack
293
314
if ( this . zip ) {
294
315
this . zip . end ( EOF )
295
316
} else {
296
- super . write ( EOF )
317
+ super . write ( EOF as unknown as string )
297
318
super . end ( )
298
319
}
299
320
}
@@ -432,7 +453,7 @@ export class Pack
432
453
} )
433
454
} else {
434
455
source . on ( 'data' , chunk => {
435
- if ( ! super . write ( chunk ) ) {
456
+ if ( ! super . write ( chunk as unknown as string ) ) {
436
457
source . pause ( )
437
458
}
438
459
} )
0 commit comments