Add EnvironmentVariableScope parameter to getEnvironmentVariables for targeted variable retrieval #689
+96
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new optional
scope
parameter to thegetEnvironmentVariables
function to allow callers to specify which types of environment variables they need. This addresses the issue where different use cases require different subsets of environment variables.Changes
New EnvironmentVariableScope Enum
Added a new enum with three values:
Process = 1
: Core environment variables required for Python process execution (e.g., PATH, PYTHONPATH, PYTHONHOME)Terminal = 2
: User-defined environment variables from .env files for terminal injectionAll = Process | Terminal
: Combines both scopes (default behavior for backward compatibility)API Enhancement
Updated the
getEnvironmentVariables
function signature:Implementation Logic
All
for backward compatibilityUsage Updates
Updated
terminalEnvVarInjector.ts
to useTerminal
scope for more targeted environment variable injection, ensuring only .env file variables are injected into terminals.Use Cases
Terminal Injection
Process Creation
Backward Compatibility
Testing
Added comprehensive tests validating:
Fixes #688.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.