Skip to content

Commit

Permalink
Also do it for exec and execObservable
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Oct 24, 2023
1 parent 386f9bf commit 454de96
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/client/common/process/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export class ProcessService extends EventEmitter implements IProcessService {
}

public execObservable(file: string, args: string[], options: SpawnOptions = {}): ObservableExecutionResult<string> {
const result = execObservable(file, args, options, this.env, this.processesToKill);
const execOptions = { ...options, doNotLog: true };
const result = execObservable(file, args, execOptions, this.env, this.processesToKill);
this.emit('exec', file, args, options);
return result;
}

public exec(file: string, args: string[], options: SpawnOptions = {}): Promise<ExecutionResult<string>> {
const promise = plainExec(file, args, options, this.env, this.processesToKill);
const execOptions = { ...options, doNotLog: true };
const promise = plainExec(file, args, execOptions, this.env, this.processesToKill);
this.emit('exec', file, args, options);
return promise;
}
Expand Down
12 changes: 10 additions & 2 deletions src/client/common/process/rawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ export function shellExec(
export function plainExec(
file: string,
args: string[],
options: SpawnOptions = {},
options: SpawnOptions & { doNotLog?: boolean } = {},
defaultEnv?: EnvironmentVariables,
disposables?: Set<IDisposable>,
): Promise<ExecutionResult<string>> {
const spawnOptions = getDefaultOptions(options, defaultEnv);
const encoding = spawnOptions.encoding ? spawnOptions.encoding : 'utf8';
if (!options.doNotLog) {
const processLogger = new ProcessLogger(new WorkspaceService());
processLogger.logProcess(file, args, options);
}
const proc = spawn(file, args, spawnOptions);
// Listen to these errors (unhandled errors in streams tears down the process).
// Errors will be bubbled up to the `error` event in `proc`, hence no need to log.
Expand Down Expand Up @@ -198,12 +202,16 @@ function removeCondaRunMarkers(out: string) {
export function execObservable(
file: string,
args: string[],
options: SpawnOptions = {},
options: SpawnOptions & { doNotLog?: boolean } = {},
defaultEnv?: EnvironmentVariables,
disposables?: Set<IDisposable>,
): ObservableExecutionResult<string> {
const spawnOptions = getDefaultOptions(options, defaultEnv);
const encoding = spawnOptions.encoding ? spawnOptions.encoding : 'utf8';
if (!options.doNotLog) {
const processLogger = new ProcessLogger(new WorkspaceService());
processLogger.logProcess(file, args, options);
}
const proc = spawn(file, args, spawnOptions);
let procExited = false;
const disposable: IDisposable = {
Expand Down

0 comments on commit 454de96

Please sign in to comment.