Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Nov 17, 2023
1 parent 39718c8 commit 65d27c2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/client/common/process/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { IDisposable } from '../types';
import { EnvironmentVariables } from '../variables/types';
import { execObservable, killPid, plainExec, shellExec } from './rawProcessApis';
import { ExecutionResult, IProcessService, ObservableExecutionResult, ShellOptions, SpawnOptions } from './types';
import { workerPlainExec, workerShellExec } from './worker/rawProcessApiWrapper';
import { workerPlainExec } from './worker/workerPlainExec';
import { workerShellExec } from './worker/workerShellExec';

export class ProcessService extends EventEmitter implements IProcessService {
private processesToKill = new Set<IDisposable>();
Expand Down
26 changes: 0 additions & 26 deletions src/client/common/process/worker/rawProcessApiWrapper.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { SpawnOptions } from 'child_process';
import { isMainThread, parentPort, workerData } from 'worker_threads';
import { executeWorkerFile } from './main';
import { ExecutionResult } from './types';

import { _workerPlainExecImpl } from './workerRawProcessApis';

export function workerPlainExec(
file: string,
args: string[],
options: SpawnOptions = {},
): Promise<ExecutionResult<string>> {
return executeWorkerFile(__filename, {
file,
args,
options,
});
}

if (!isMainThread) {
_workerPlainExecImpl(workerData.file, workerData.args, workerData.options)
.then((res) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { isMainThread, parentPort, workerData } from 'worker_threads';
import { executeWorkerFile } from './main';
import { ExecutionResult, ShellOptions } from './types';
import { _workerShellExecImpl } from './workerRawProcessApis';

export function workerShellExec(command: string, options: ShellOptions): Promise<ExecutionResult<string>> {
return executeWorkerFile(__filename, {
command,
options,
});
}

if (!isMainThread) {
_workerShellExecImpl(workerData.command, workerData.options, workerData.defaultEnv)
.then((res) => {
Expand Down

0 comments on commit 65d27c2

Please sign in to comment.