mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-24 02:18:40 +08:00
[Windows] Use common approach to set machine vars (#8830)
This commit is contained in:
committed by
GitHub
parent
045a0de8e2
commit
07e8da79f8
@@ -19,7 +19,6 @@ Export-ModuleMember -Function @(
|
||||
'Add-DefaultItem'
|
||||
'Get-SystemVariable'
|
||||
'Get-DefaultVariable'
|
||||
'Set-SystemVariable'
|
||||
'Set-DefaultVariable'
|
||||
'Install-Binary'
|
||||
'Install-VisualStudio'
|
||||
|
||||
@@ -54,16 +54,6 @@ function Get-DefaultVariable {
|
||||
[System.GC]::Collect()
|
||||
}
|
||||
|
||||
function Set-SystemVariable {
|
||||
param(
|
||||
[string]$SystemVariable,
|
||||
[string]$Value
|
||||
)
|
||||
|
||||
[System.Environment]::SetEnvironmentVariable($SystemVariable, $Value, "Machine")
|
||||
Get-SystemVariable $SystemVariable
|
||||
}
|
||||
|
||||
function Set-DefaultVariable {
|
||||
param(
|
||||
[string]$DefaultVariable,
|
||||
@@ -93,7 +83,7 @@ function Set-MachinePath {
|
||||
[string]$NewPath
|
||||
)
|
||||
|
||||
Set-SystemVariable PATH $NewPath
|
||||
[System.Environment]::SetEnvironmentVariable("PATH", $NewPath, "Machine")
|
||||
}
|
||||
|
||||
function Set-DefaultPath {
|
||||
|
||||
@@ -25,10 +25,3 @@ Describe "Add-MachinePathItem Tests"{
|
||||
Add-MachinePathItem -PathItem 'C:\baz' | Should Be 'C:\baz;C:\foo;C:\bar'
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Set-SystemVariable Tests' {
|
||||
Mock Set-ItemProperty {return}
|
||||
It 'Set-SystemVariable should return new path' {
|
||||
Set-SystemVariable -SystemVariable "NewPathVar" -Value "C:\baz" | Should Be "C:\baz"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user