@@ -7,6 +7,7 @@ import { IDisposable } from '../types';
77import { EnvironmentVariables } from '../variables/types' ;
88import { execObservable , killPid , plainExec , shellExec } from './rawProcessApis' ;
99import { ExecutionResult , IProcessService , ObservableExecutionResult , ShellOptions , SpawnOptions } from './types' ;
10+ import { workerPlainExec , workerShellExec } from './worker/rawProcessApiWrapper' ;
1011
1112export class ProcessService extends EventEmitter implements IProcessService {
1213 private processesToKill = new Set < IDisposable > ( ) ;
@@ -47,14 +48,20 @@ export class ProcessService extends EventEmitter implements IProcessService {
4748 }
4849
4950 public exec ( file : string , args : string [ ] , options : SpawnOptions = { } ) : Promise < ExecutionResult < string > > {
51+ this . emit ( 'exec' , file , args , options ) ;
52+ if ( options . useWorker ) {
53+ return workerPlainExec ( file , args , options ) ;
54+ }
5055 const execOptions = { ...options , doNotLog : true } ;
5156 const promise = plainExec ( file , args , execOptions , this . env , this . processesToKill ) ;
52- this . emit ( 'exec' , file , args , options ) ;
5357 return promise ;
5458 }
5559
5660 public shellExec ( command : string , options : ShellOptions = { } ) : Promise < ExecutionResult < string > > {
5761 this . emit ( 'exec' , command , undefined , options ) ;
62+ if ( options . useWorker ) {
63+ return workerShellExec ( command , options ) ;
64+ }
5865 const disposables = new Set < IDisposable > ( ) ;
5966 const shellOptions = { ...options , doNotLog : true } ;
6067 return shellExec ( command , shellOptions , this . env , disposables ) . finally ( ( ) => {
0 commit comments