Skip to content

Commit 55bba1b

Browse files
committed
feat: move envResolver to a different file
1 parent 8fa60f2 commit 55bba1b

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

src/envResolver.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Resolves environment variables in a string
3+
* Supports: ${env:VAR_NAME}
4+
*/
5+
export function resolveEnvVariables(value: string): string {
6+
// Replace ${env:VAR_NAME} with environment variable values
7+
return value.replace(/\$\{env:([^}]+)\}/g, (match, envVar: string) => {
8+
const envValue = process.env[envVar]
9+
return envValue !== undefined ? envValue : match
10+
})
11+
}

src/extension.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@ import { WorkspaceFolder, DebugConfiguration, CancellationToken } from 'vscode'
33
import { LaunchRequestArguments } from './phpDebug'
44
import * as which from 'which'
55
import * as path from 'path'
6-
7-
/**
8-
* Resolves environment variables in a string
9-
* Supports: ${env:VAR_NAME}
10-
*/
11-
export function resolveEnvVariables(value: string): string {
12-
// Replace ${env:VAR_NAME} with environment variable values
13-
return value.replace(/\$\{env:([^}]+)\}/g, (match, envVar: string) => {
14-
const envValue = process.env[envVar]
15-
return envValue !== undefined ? envValue : match
16-
})
17-
}
6+
import { resolveEnvVariables } from './envResolver'
187

198
export function activate(context: vscode.ExtensionContext) {
209
context.subscriptions.push(

src/test/envResolver.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { assert } from 'chai'
22
import { describe, it, beforeEach, afterEach } from 'mocha'
3-
4-
// Inline the function for testing without vscode dependency
5-
function resolveEnvVariables(value: string): string {
6-
return value.replace(/\$\{env:([^}]+)\}/g, (match, envVar: string) => {
7-
const envValue = process.env[envVar]
8-
return envValue !== undefined ? envValue : match
9-
})
10-
}
3+
import { resolveEnvVariables } from '../envResolver'
114

125
describe('Environment Variable Resolution', () => {
136
let originalEnv: NodeJS.ProcessEnv

0 commit comments

Comments
 (0)