MCPcopy Create free account
hub / github.com/xpf0000/FlyEnv / buildSetSystemPathScript

Function buildSetSystemPathScript

src/shared/WindowsHelperFallback.ts:606–642  ·  view source on GitHub ↗
(args: ValidatedSetSystemPathArgs, tempFilePath?: string)

Source from the content-addressed store, hash-verified

604}
605
606function buildSetSystemPathScript(args: ValidatedSetSystemPathArgs, tempFilePath?: string): string {
607 const runtimeSetup = tempFilePath
608 ? `$payload = Get-Content -LiteralPath ${powerShellString(tempFilePath)} -Raw | ConvertFrom-Json
609$paths = @($payload.paths)
610$otherVars = @{}
611if ($payload.otherVars) {
612 foreach ($property in $payload.otherVars.PSObject.Properties) {
613 $otherVars[[string]$property.Name] = [string]$property.Value
614 }
615}`
616 : (() => {
617 const pathsArray = args.paths.map((entry) => powerShellString(entry)).join(', ')
618 const otherVarsBody = Object.entries(args.otherVars)
619 .map(([key, value]) => `${powerShellString(key)} = ${powerShellString(value)}`)
620 .join('; ')
621 return `$paths = @(${pathsArray})
622$otherVars = ${otherVarsBody ? `@{ ${otherVarsBody} }` : '@{}'}`
623 })()
624 return `${buildPowerShellPreamble()}
625${runtimeSetup}
626$pathValue = (($paths | Where-Object { $_ -and $_.ToString().Trim().Length -gt 0 }) -join ';') + ';'
627New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'Path' -Value $pathValue -PropertyType ExpandString -Force | Out-Null
628foreach ($entry in $otherVars.GetEnumerator()) {
629 $name = [string]$entry.Key
630 $value = [string]$entry.Value
631 if ($value.Contains('%')) {
632 New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $name -Value $value -PropertyType ExpandString -Force | Out-Null
633 }
634 else {
635 New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $name -Value $value -PropertyType String -Force | Out-Null
636 Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name $name -Value $value
637 }
638}
639New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'FLYENV_ENV_FLUSH' -Value '0' -PropertyType String -Force | Out-Null
640Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'FLYENV_ENV_FLUSH' -Value '0'
641${buildNotifyEnvironmentChangedScript()}`
642}
643
644function buildSetSystemEnvScript(args: ValidatedSetSystemEnvArgs, tempFilePath?: string): string {
645 const runtimeSetup = tempFilePath

Callers 1

Calls 3

powerShellStringFunction · 0.85
buildPowerShellPreambleFunction · 0.85

Tested by

no test coverage detected