Use powershell to get Windows temporary dir
Leverages Powershell script to work both in Windows and WSL.
This commit is contained in:
parent
57087d335c
commit
71f5b0f97f
|
@ -656,10 +656,8 @@ module Vagrant
|
|||
# @return [String, Nil]
|
||||
def windows_temp
|
||||
if !@_windows_temp
|
||||
result = Util::Subprocess.execute("cmd.exe", "/c", "echo %TEMP%")
|
||||
if result.exit_code == 0
|
||||
@_windows_temp = result.stdout.gsub("\"", "").strip
|
||||
end
|
||||
result = Vagrant::Util::PowerShell.execute_cmd("(Get-Item Env:TEMP).Value")
|
||||
@_windows_temp = result.gsub("\"", "").strip
|
||||
end
|
||||
@_windows_temp
|
||||
end
|
||||
|
|
|
@ -538,8 +538,8 @@ EOF
|
|||
let(:temp_dir) { 'C:\Users\User\AppData\Local\Temp' }
|
||||
|
||||
it "should return windows temporary directory" do
|
||||
allow(Vagrant::Util::Subprocess).to receive(:execute).
|
||||
with("cmd.exe", "/c", "echo %TEMP%").and_return(double(exit_code: 0, stdout: temp_dir))
|
||||
allow(Vagrant::Util::PowerShell).to receive(:execute).
|
||||
with("(Get-Item Env:TEMP).Value").and_return(temp_dir)
|
||||
expect(subject.windows_temp).to eql(temp_dir)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue