1- import { spawn } from 'child_process' ;
21import { EventEmitter } from 'events' ;
3- import { decorate , inject , injectable } from 'inversify' ;
4- import * as Rx from 'rxjs' ;
5- import { Disposable } from 'vscode ' ;
6- import { ExecutionResult , IBufferDecoder , IProcessService , ObservableExecutionResult , Output , SpawnOptions } from '../../client/common/process/types' ;
2+ import { inject , injectable } from 'inversify' ;
3+ import 'rxjs/add/observable/of ' ;
4+ import { Observable } from 'rxjs/Observable ' ;
5+ import { ExecutionResult , IProcessService , ObservableExecutionResult , Output , SpawnOptions } from '../../client/common/process/types' ;
76
8- type ExecObservableCallback = ( result : Rx . Observable < Output < string > > | Output < string > ) => void ;
7+ type ExecObservableCallback = ( result : Observable < Output < string > > | Output < string > ) => void ;
98type ExecCallback = ( result : ExecutionResult < string > ) => void ;
109
1110export const IOriginalProcessService = Symbol ( 'IProcessService' ) ;
1211
1312@injectable ( )
1413export class MockProcessService extends EventEmitter implements IProcessService {
15- private observableResults : ( Rx . Observable < Output < string > > | Output < string > ) [ ] = [ ] ;
1614 constructor ( @inject ( IOriginalProcessService ) private procService : IProcessService ) {
1715 super ( ) ;
1816 }
1917 public onExecObservable ( handler : ( file : string , args : string [ ] , options : SpawnOptions , callback : ExecObservableCallback ) => void ) {
2018 this . on ( 'execObservable' , handler ) ;
2119 }
2220 public execObservable ( file : string , args : string [ ] , options : SpawnOptions = { } ) : ObservableExecutionResult < string > {
23- let value : Rx . Observable < Output < string > > | Output < string > | undefined ;
21+ let value : Observable < Output < string > > | Output < string > | undefined ;
2422 let valueReturned = false ;
25- this . emit ( 'execObservable' , file , args , options , ( result : Rx . Observable < Output < string > > | Output < string > ) => { value = result ; valueReturned = true ; } ) ;
23+ this . emit ( 'execObservable' , file , args , options , ( result : Observable < Output < string > > | Output < string > ) => { value = result ; valueReturned = true ; } ) ;
2624
2725 if ( valueReturned ) {
2826 const output = value as Output < string > ;
2927 if ( [ 'stderr' , 'stdout' ] . some ( source => source === output . source ) ) {
3028 return {
3129 // tslint:disable-next-line:no-any
3230 proc : { } as any ,
33- out : Rx . Observable . of ( output )
31+ out : Observable . of ( output )
3432 } ;
3533 } else {
3634 return {
3735 // tslint:disable-next-line:no-any
3836 proc : { } as any ,
39- out : value as Rx . Observable < Output < string > >
37+ out : value as Observable < Output < string > >
4038 } ;
4139 }
4240 } else {
@@ -51,6 +49,6 @@ export class MockProcessService extends EventEmitter implements IProcessService
5149 let valueReturned = false ;
5250 this . emit ( 'exec' , file , args , options , ( result : ExecutionResult < string > ) => { value = result ; valueReturned = true ; } ) ;
5351
54- return valueReturned ? value : this . procService . exec ( file , args , options ) ;
52+ return valueReturned ? value ! : this . procService . exec ( file , args , options ) ;
5553 }
5654}
0 commit comments