@@ -31,7 +31,6 @@ export class PackJob {
3131
3232import { Minipass } from 'minipass'
3333import * as zlib from 'minizlib'
34- //@ts -ignore
3534import { Yallist } from 'yallist'
3635import { ReadEntry } from './read-entry.js'
3736import {
@@ -68,7 +67,7 @@ import { normalizeWindowsPath } from './normalize-windows-path.js'
6867import { TarOptions } from './options.js'
6968
7069export class Pack
71- extends Minipass < Minipass . ContiguousData , Buffer , WarnEvent >
70+ extends Minipass < Buffer , ReadEntry | string , WarnEvent < Buffer > >
7271 implements Warner
7372{
7473 opt : TarOptions
@@ -99,6 +98,7 @@ export class Pack
9998 [ ENDED ] : boolean = false
10099
101100 constructor ( opt : TarOptions = { } ) {
101+ //@ts -ignore
102102 super ( )
103103 this . opt = opt
104104 this . file = opt . file || ''
@@ -142,7 +142,7 @@ export class Pack
142142 /* c8 ignore next */
143143 if ( ! this . zip ) throw new Error ( 'impossible' )
144144 const zip = this . zip
145- zip . on ( 'data' , chunk => super . write ( chunk ) )
145+ zip . on ( 'data' , chunk => super . write ( chunk as unknown as string ) )
146146 zip . on ( 'end' , ( ) => super . end ( ) )
147147 zip . on ( 'drain' , ( ) => this [ ONDRAIN ] ( ) )
148148 this . on ( 'resume' , ( ) => zip . resume ( ) )
@@ -166,25 +166,46 @@ export class Pack
166166 }
167167
168168 [ WRITE ] ( chunk : Buffer ) {
169- return super . write ( chunk )
169+ return super . write ( chunk as unknown as string )
170170 }
171171
172172 add ( path : string | ReadEntry ) {
173173 this . write ( path )
174174 return this
175175 }
176176
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 */
179199 if ( path ) {
180200 this . add ( path )
181201 }
182202 this [ ENDED ] = true
183203 this [ PROCESS ] ( )
204+ /* c8 ignore next */
205+ if ( cb ) cb ( )
184206 return this
185207 }
186208
187- //@ts -ignore
188209 write ( path : string | ReadEntry ) {
189210 if ( this [ ENDED ] ) {
190211 throw new Error ( 'write after end' )
@@ -293,7 +314,7 @@ export class Pack
293314 if ( this . zip ) {
294315 this . zip . end ( EOF )
295316 } else {
296- super . write ( EOF )
317+ super . write ( EOF as unknown as string )
297318 super . end ( )
298319 }
299320 }
@@ -432,7 +453,7 @@ export class Pack
432453 } )
433454 } else {
434455 source . on ( 'data' , chunk => {
435- if ( ! super . write ( chunk ) ) {
456+ if ( ! super . write ( chunk as unknown as string ) ) {
436457 source . pause ( )
437458 }
438459 } )
0 commit comments