MCPcopy Create free account
hub / github.com/pingdotgg/t3code / buildWindowsEnvironmentCaptureCommand

Function buildWindowsEnvironmentCaptureCommand

packages/shared/src/shell.ts:263–279  ·  view source on GitHub ↗
(names: ReadonlyArray<string>)

Source from the content-addressed store, hash-verified

261}
262
263function buildWindowsEnvironmentCaptureCommand(names: ReadonlyArray<string>): string {
264 return [
265 "$ErrorActionPreference = 'Stop'",
266 ...names.flatMap((name) => {
267 if (!SHELL_ENV_NAME_PATTERN.test(name)) {
268 throw new Error(`Unsupported environment variable name: ${name}`);
269 }
270
271 return [
272 `Write-Output '${envCaptureStart(name)}'`,
273 `$value = [Environment]::GetEnvironmentVariable('${name}')`,
274 "if ($null -ne $value -and $value.Length -gt 0) { Write-Output $value }",
275 `Write-Output '${envCaptureEnd(name)}'`,
276 ];
277 }),
278 ].join("; ");
279}
280
281function extractEnvironmentValue(output: string, name: string): string | undefined {
282 const startMarker = envCaptureStart(name);

Callers 1

Calls 2

envCaptureStartFunction · 0.85
envCaptureEndFunction · 0.85

Tested by

no test coverage detected