File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed
Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -319,12 +319,12 @@ export class ProcessPromise extends Promise<ProcessOutput> {
319319
320320 // Essentials
321321 pipe ( dest : TemplateStringsArray , ...args : any [ ] ) : ProcessPromise
322- pipe < D extends Writable > ( dest : D ) : D & PromiseLike < void >
322+ pipe < D extends Writable > ( dest : D ) : D & PromiseLike < D >
323323 pipe < D extends ProcessPromise > ( dest : D ) : D
324324 pipe (
325325 dest : Writable | ProcessPromise | TemplateStringsArray ,
326326 ...args : any [ ]
327- ) : ( Writable & PromiseLike < void > ) | ProcessPromise {
327+ ) : ( Writable & PromiseLike < Writable > ) | ProcessPromise {
328328 if ( isStringLiteral ( dest , ...args ) )
329329 return this . pipe ( $ ( dest as TemplateStringsArray , ...args ) )
330330 if ( isString ( dest ) )
Original file line number Diff line number Diff line change @@ -453,21 +453,21 @@ export const once = <T extends (...args: any[]) => any>(fn: T) => {
453453
454454export const promisifyStream = < S extends Writable > (
455455 stream : S
456- ) : S & PromiseLike < void > =>
457- new Proxy ( stream as S & PromiseLike < void > , {
456+ ) : S & PromiseLike < S > =>
457+ new Proxy ( stream as S & PromiseLike < S > , {
458458 get ( target , key ) {
459459 if ( key === 'then' ) {
460460 return ( res : any = noop , rej : any = noop ) =>
461461 new Promise ( ( _res , _rej ) =>
462462 target
463- . once ( 'error' , ( ) => _rej ( rej ( ) ) )
464- . once ( 'finish' , ( ) => _res ( res ( ) ) )
463+ . once ( 'error' , ( e ) => _rej ( rej ( e ) ) )
464+ . once ( 'finish' , ( ) => _res ( res ( target ) ) )
465465 )
466466 }
467467 const value = Reflect . get ( target , key )
468468 if ( key === 'pipe' && typeof value === 'function' ) {
469469 return function ( ...args : any ) {
470- return promisifyStream ( value . apply ( target , args ) as S )
470+ return promisifyStream ( value . apply ( target , args ) )
471471 }
472472 }
473473 return value
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ expectType<ProcessPromise>(p.nothrow())
2727expectType < ProcessPromise > ( p . quiet ( ) )
2828expectType < ProcessPromise > ( p . pipe ( $ `cmd` ) )
2929expectType < ProcessPromise > ( p . pipe `cmd` )
30- expectType < typeof process . stdout & PromiseLike < void > > ( p . pipe ( process . stdout ) )
30+ expectType < typeof process . stdout & PromiseLike < typeof process . stdout > > (
31+ p . pipe ( process . stdout )
32+ )
3133expectType < ProcessPromise > ( p . stdio ( 'pipe' ) )
3234expectType < ProcessPromise > ( p . timeout ( '1s' ) )
3335expectType < Promise < void > > ( p . kill ( ) )
Original file line number Diff line number Diff line change @@ -411,6 +411,7 @@ describe('core', () => {
411411
412412 test ( '$ > stream' , async ( ) => {
413413 const file = tempfile ( )
414+ const fileStream = fs . createWriteStream ( file )
414415 const p = $ `echo "hello"`
415416 . pipe (
416417 new Transform ( {
@@ -419,10 +420,10 @@ describe('core', () => {
419420 } ,
420421 } )
421422 )
422- . pipe ( fs . createWriteStream ( file ) )
423+ . pipe ( fileStream )
423424
424425 assert . ok ( p instanceof WriteStream )
425- assert . equal ( await p , undefined )
426+ assert . equal ( await p , fileStream )
426427 assert . equal ( ( await fs . readFile ( file ) ) . toString ( ) , 'HELLO\n' )
427428 await fs . rm ( file )
428429 } )
You can’t perform that action at this time.
0 commit comments