Skip to content

Commit 6db24ce

Browse files
committed
cleanup
1 parent 2d0ab80 commit 6db24ce

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

src/features/terminal/terminalEnvVarInjector.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import * as fsapi from 'fs-extra';
4+
import * as fse from 'fs-extra';
55
import * as path from 'path';
66
import {
77
Disposable,
@@ -82,8 +82,7 @@ export class TerminalEnvVarInjector implements Disposable {
8282
);
8383
await this.injectEnvironmentVariablesForWorkspace(workspaceFolder);
8484
} else {
85-
// Initial load - update all workspaces
86-
traceVerbose('TerminalEnvVarInjector: Clearing existing environment variables for initial load');
85+
// No provided workspace - update all workspaces
8786
this.envVarCollection.clear();
8887

8988
const workspaceFolders = workspace.workspaceFolders;
@@ -115,29 +114,26 @@ export class TerminalEnvVarInjector implements Disposable {
115114
// Track which .env file is being used for logging
116115
const config = getConfiguration('python', workspaceUri); // why did this get .env file?? // returns like all of them
117116
const envFilePath = config.get<string>('envFile');
118-
const resolvedEnvFilePath = envFilePath
117+
const resolvedEnvFilePath: string | undefined = envFilePath
119118
? path.resolve(resolveVariables(envFilePath, workspaceUri))
120119
: undefined;
121-
const defaultEnvFilePath = path.join(workspaceUri.fsPath, '.env');
122-
123-
let activeEnvFilePath: string | undefined;
124-
if (resolvedEnvFilePath && (await fsapi.pathExists(resolvedEnvFilePath))) {
125-
activeEnvFilePath = resolvedEnvFilePath;
126-
traceVerbose(`TerminalEnvVarInjector: Using python.envFile setting: ${activeEnvFilePath}`);
127-
} else if (await fsapi.pathExists(defaultEnvFilePath)) {
128-
activeEnvFilePath = defaultEnvFilePath;
129-
traceVerbose(`TerminalEnvVarInjector: Using default .env file: ${activeEnvFilePath}`);
120+
const defaultEnvFilePath: string = path.join(workspaceUri.fsPath, '.env');
121+
122+
let activeEnvFilePath: string = resolvedEnvFilePath || defaultEnvFilePath;
123+
if (activeEnvFilePath && (await fse.pathExists(activeEnvFilePath))) {
124+
traceVerbose(`TerminalEnvVarInjector: Using env file: ${activeEnvFilePath}`);
130125
} else {
131-
traceVerbose(`TerminalEnvVarInjector: No .env file found for workspace: ${workspaceUri.fsPath}`);
126+
traceVerbose(
127+
`TerminalEnvVarInjector: No .env file found for workspace: ${workspaceUri.fsPath}, not injecting environment variables.`,
128+
);
132129
return; // No .env file to inject
133130
}
134131

132+
// use scoped environment variable collection
135133
const envVarScope = this.getEnvironmentVariableCollectionScoped({ workspaceFolder });
136134
envVarScope.clear(); // Clear existing variables for this workspace
137-
138-
// Inject environment variables into the collection
135+
139136
for (const [key, value] of Object.entries(envVars)) {
140-
// inject into correctly scoped environment collection
141137
if (value === undefined) {
142138
// Remove the environment variable if the value is undefined
143139
envVarScope.delete(key);

0 commit comments

Comments
 (0)