[macOS] Refactor Common.Helpers (#8924)

* [macOS] Refactor Common.Helpers

* Update readme file

* Remove unnecessary double quotes

---------

Co-authored-by: Alexey Ayupov <“alexey.ayupov@akvelon.com”>
This commit is contained in:
Alexey-Ayupov
2023-12-04 12:13:08 +01:00
committed by GitHub
parent ff1dc02cbc
commit 69db5c6c63
46 changed files with 292 additions and 359 deletions

View File

@@ -6,8 +6,7 @@
Import-Module "~/image-generation/helpers/Common.Helpers.psm1"
function Get-ToolsetToolFullPath
{
function Get-ToolsetToolFullPath {
param
(
[Parameter(Mandatory)] [string] $ToolName,
@@ -23,25 +22,23 @@ function Get-ToolsetToolFullPath
}
$arch = Get-Architecture
$toolcache = Get-ToolsetValue "toolcache"
$toolcache = (Get-ToolsetContent).toolcache
foreach ($tool in $toolcache)
{
foreach ($tool in $toolcache) {
$toolName = $tool.name
$toolEnvironment = $tool.arch.$arch.variable_template
if (-not $toolEnvironment)
{
if (-not $toolEnvironment) {
continue
}
foreach ($toolVersion in $tool.arch.$arch.versions)
{
foreach ($toolVersion in $tool.arch.$arch.versions) {
Write-Host "Set $toolName $toolVersion environment variable..."
$toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch
$envName = $toolEnvironment -f $toolVersion.split(".")
# Add environment variable name=value
Add-EnvironmentVariable -Name $envName -Value $toolPath
$envVar = "export {0}={1}" -f $envName, $toolPath
Add-Content -Path "${env:HOME}/.bashrc" -Value $envVar
}
}