(args: ValidatedSetSystemPathArgs, tempFilePath?: string)
| 604 | } |
| 605 | |
| 606 | function 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 = @{} |
| 611 | if ($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 ';') + ';' |
| 627 | New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'Path' -Value $pathValue -PropertyType ExpandString -Force | Out-Null |
| 628 | foreach ($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 | } |
| 639 | New-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'FLYENV_ENV_FLUSH' -Value '0' -PropertyType String -Force | Out-Null |
| 640 | Set-ItemProperty -LiteralPath ${powerShellString(MACHINE_ENV_REGISTRY_PATH)} -Name 'FLYENV_ENV_FLUSH' -Value '0' |
| 641 | ${buildNotifyEnvironmentChangedScript()}` |
| 642 | } |
| 643 | |
| 644 | function buildSetSystemEnvScript(args: ValidatedSetSystemEnvArgs, tempFilePath?: string): string { |
| 645 | const runtimeSetup = tempFilePath |
no test coverage detected