|
6 | 6 | import * as cp from "child_process"; |
7 | 7 | import * as os from 'os'; |
8 | 8 | import * as path from 'path'; |
9 | | -import { CustomExecution, Disposable, Event, EventEmitter, ProcessExecution, Pseudoterminal, ShellExecution, Task, TaskDefinition, TaskEndEvent, TaskExecution, TaskGroup, TaskProvider, tasks, TaskScope, TerminalDimensions, TextEditor, window, workspace, WorkspaceFolder } from 'vscode'; |
| 9 | +import { CustomExecution, Disposable, EnvironmentVariableMutator, Event, EventEmitter, ProcessExecution, Pseudoterminal, ShellExecution, Task, TaskDefinition, TaskEndEvent, TaskExecution, TaskGroup, TaskProvider, tasks, TaskScope, TerminalDimensions, TextEditor, window, workspace, WorkspaceFolder } from 'vscode'; |
10 | 10 | import * as nls from 'vscode-nls'; |
11 | 11 | import * as util from '../common'; |
12 | 12 | import * as telemetry from '../telemetry'; |
13 | 13 | import { Client } from './client'; |
14 | 14 | import * as configs from './configurations'; |
| 15 | +import { isEnvironmentOverrideApplied } from "./devcmd"; |
15 | 16 | import * as ext from './extension'; |
16 | 17 | import { OtherSettings } from './settings'; |
17 | 18 |
|
@@ -430,6 +431,22 @@ class CustomBuildTaskTerminal implements Pseudoterminal { |
430 | 431 | } |
431 | 432 | } |
432 | 433 |
|
| 434 | + if (isEnvironmentOverrideApplied(util.extensionContext)) { |
| 435 | + // If the user has applied the Developer Environment to this workspace, it should apply to all newly opened terminals. |
| 436 | + // However, this does not apply to processes that we spawn ourselves in the Pseudoterminal, so we need to specify the |
| 437 | + // correct environment in order to emulate the terminal behavior properly. |
| 438 | + const env = { ...process.env }; |
| 439 | + util.extensionContext?.environmentVariableCollection.forEach((variable: string, mutator: EnvironmentVariableMutator) => { |
| 440 | + if (variable.toLowerCase() === "path") { |
| 441 | + // Path is special because it has a placeholder to insert the current Path into. |
| 442 | + env[variable] = util.resolveVariables(mutator.value); |
| 443 | + } else { |
| 444 | + env[variable] = mutator.value; |
| 445 | + } |
| 446 | + }); |
| 447 | + this.options.env = env; |
| 448 | + } |
| 449 | + |
433 | 450 | const splitWriteEmitter = (lines: string | Buffer) => { |
434 | 451 | const splitLines: string[] = lines.toString().split(/\r?\n/g); |
435 | 452 | for (let i: number = 0; i < splitLines.length; i++) { |
|
0 commit comments