@@ -191,16 +191,21 @@ Describe "Get-Item environment provider on Windows with accidental case-variant
191
191
if (-not (Get-Command - ErrorAction Ignore node.exe )) {
192
192
Write-Warning " Test skipped, because prerequisite Node.js is not installed."
193
193
} else {
194
- $valDirect , $valGetItem , $unused = node.exe - pe @"
194
+ $fso = New-Object - ComObject Scripting.FileSystemObject
195
+ $shortPath = $fso.GetFile (" $PSHOME \pwsh.exe" ).ShortPath.Replace(' \' , ' /' )
196
+ $script = @"
195
197
env = {}
196
198
env.testVar = process.env.testVar // include the original case variant with its original value.
197
199
env.TESTVAR = 'b' // redefine with a case variant name and different value
198
200
// Note: Which value will win is not deterministic(!); what matters, however, is that both
199
- // $env: testvar and Get-Item env:testvar report the same value.
201
+ // ` $ env:testvar and Get-Item env:testvar report the same value.
200
202
// The nondeterministic behavior makes it hard to prove that the values are *always* the
201
203
// same, however.
202
- require('child_process').execSync(\"\\\" $ ( $PSHOME -replace ' \\ ' , ' / ' ) /pwsh.exe\\\" - noprofile -command `$ env:testvar, (Get-Item env:testvar).Value\" , { env: env }).toString()
204
+ require('child_process').execSync(' $shortPath - noprofile -command `$ env:testvar, (Get-Item env:testvar).Value' , { env: env }).toString()
203
205
"@
206
+ $valDirect , $valGetItem , $unused = node.exe - pe $script
207
+ $LASTEXITCODE | Should - Be 0
208
+ $valDirect | Should -Not - BeNullOrEmpty
204
209
$valGetItem | Should - BeExactly $valDirect
205
210
}
206
211
}
0 commit comments