Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Nov 16, 2023
1 parent 446162e commit 4f8fbd9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/client/common/process/worker/rawProcessApiWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@

import { SpawnOptions } from 'child_process';
import * as path from 'path';
import { IProcessLogger } from '../types';
import { executeWorkerFile } from './main';
import { EnvironmentVariables, ExecutionResult, ShellOptions } from './types';

export function workerShellExec(
command: string,
options: ShellOptions,
processLogger: IProcessLogger,
defaultEnv?: EnvironmentVariables,
): Promise<ExecutionResult<string>> {
processLogger.logProcess(command, undefined, options);
return executeWorkerFile(path.join(__dirname, 'shellExecWorker.js'), {
command,
options,
Expand All @@ -21,13 +24,13 @@ export function workerShellExec(
export function workerPlainExec(
file: string,
args: string[],
options: SpawnOptions & { doNotLog?: boolean } = {},
defaultEnv?: EnvironmentVariables,
options: SpawnOptions = {},
processLogger: IProcessLogger,
): Promise<ExecutionResult<string>> {
processLogger.logProcess(file, args, options);
return executeWorkerFile(path.join(__dirname, 'plainExecWorker.js'), {
file,
args,
options,
defaultEnv,
});
}
14 changes: 11 additions & 3 deletions src/client/pythonEnvironments/common/externalDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import * as fsapi from 'fs-extra';
import * as path from 'path';
import * as vscode from 'vscode';
import { IWorkspaceService } from '../../common/application/types';
import { ExecutionResult, IProcessServiceFactory, ShellOptions, SpawnOptions } from '../../common/process/types';
import {
ExecutionResult,
IProcessLogger,
IProcessServiceFactory,
ShellOptions,
SpawnOptions,
} from '../../common/process/types';
import { IDisposable, IConfigurationService, IExperimentService } from '../../common/types';
import { chain, iterable } from '../../common/utils/async';
import { getOSType, OSType } from '../../common/utils/platform';
Expand All @@ -27,10 +33,11 @@ export async function shellExecute(command: string, options: ShellOptions = {}):
const service = await internalServiceContainer.get<IProcessServiceFactory>(IProcessServiceFactory).create();
return service.shellExec(command, options);
}
const logger = internalServiceContainer.get<IProcessLogger>(IProcessLogger);
const envVarsService = internalServiceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);
const envs = await envVarsService.getEnvironmentVariables();
options.env = { ...options.env, ...envs };
return workerShellExec(command, options);
return workerShellExec(command, options, logger);
}

export async function exec(
Expand All @@ -43,10 +50,11 @@ export async function exec(
const service = await internalServiceContainer.get<IProcessServiceFactory>(IProcessServiceFactory).create();
return service.exec(file, args, options);
}
const logger = internalServiceContainer.get<IProcessLogger>(IProcessLogger);
const envVarsService = internalServiceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);
const envs = await envVarsService.getEnvironmentVariables();
options.env = { ...options.env, ...envs };
return workerPlainExec(file, args, options);
return workerPlainExec(file, args, options, logger);
}

export function inExperiment(experimentName: string): boolean {
Expand Down

0 comments on commit 4f8fbd9

Please sign in to comment.