(#10099) Properly join commands from passed in array

Prior to this commit, the `Util::Powershell.execute_inline`
method didn't properly join the passed in command and instead attempted
to execute the array of strings. This commit updates that
behavior to join the command array prior to inserting it into the full
powershell command.
This commit is contained in:
Brian Cain 2018-08-14 09:30:11 -07:00
parent 64acd68c64
commit e073153728
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
2 changed files with 9 additions and 5 deletions

View File

@ -132,6 +132,9 @@ module Vagrant
if env = opts.delete(:env)
env = env.map{|k,v| "$env:#{k}=#{v}"}.join(";") + "; "
end
command = command.join(' ')
c = [
executable,
"-NoLogo",

View File

@ -215,6 +215,7 @@ describe Vagrant::Util::PowerShell do
let(:exit_code){ 0 }
let(:stdout){ "" }
let(:stderr){ "" }
let(:command) { ["run", "--this", "custom-command"] }
before do
allow(described_class).to receive(:validate_install!)
@ -223,7 +224,7 @@ describe Vagrant::Util::PowerShell do
it "should validate installation before use" do
expect(described_class).to receive(:validate_install!)
described_class.execute_inline("command")
described_class.execute_inline(command)
end
it "should include command to execute" do
@ -232,7 +233,7 @@ describe Vagrant::Util::PowerShell do
expect(comm.to_s).to include("custom-command")
result
end
described_class.execute_inline("custom-command")
described_class.execute_inline(command)
end
it "should accept custom environment" do
@ -241,7 +242,7 @@ describe Vagrant::Util::PowerShell do
expect(comm.to_s).to include("$env:TEST_KEY=test-value")
result
end
described_class.execute_inline("custom-command", env: {"TEST_KEY" => "test-value"})
described_class.execute_inline(command, env: {"TEST_KEY" => "test-value"})
end
it "should define a custom module path" do
@ -250,11 +251,11 @@ describe Vagrant::Util::PowerShell do
expect(comm.to_s).to include("$env:PSModulePath+';C:\\My-Path'")
result
end
described_class.execute_inline("custom-command", module_path: "C:\\My-Path")
described_class.execute_inline(command, module_path: "C:\\My-Path")
end
it "should return a result instance" do
expect(described_class.execute_inline("cmd")).to eq(result)
expect(described_class.execute_inline(command)).to eq(result)
end
end