Remove console resizing on powershell commands
This commit is contained in:
parent
57842d7269
commit
ef4d431d36
|
@ -68,7 +68,7 @@ module Vagrant
|
||||||
"-NoProfile",
|
"-NoProfile",
|
||||||
"-NonInteractive",
|
"-NonInteractive",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"#{resize_console}#{env}&('#{path}')",
|
"#{env}&('#{path}')",
|
||||||
args
|
args
|
||||||
].flatten
|
].flatten
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ module Vagrant
|
||||||
"-NonInteractive",
|
"-NonInteractive",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-Command",
|
"-Command",
|
||||||
"#{resize_console}#{env}#{command}"
|
"#{env}#{command}"
|
||||||
].flatten.compact
|
].flatten.compact
|
||||||
|
|
||||||
r = Subprocess.execute(*c)
|
r = Subprocess.execute(*c)
|
||||||
|
@ -135,7 +135,7 @@ module Vagrant
|
||||||
"-NonInteractive",
|
"-NonInteractive",
|
||||||
"-ExecutionPolicy", "Bypass",
|
"-ExecutionPolicy", "Bypass",
|
||||||
"-Command",
|
"-Command",
|
||||||
"#{resize_console}#{env}#{command}"
|
"#{env}#{command}"
|
||||||
].flatten.compact
|
].flatten.compact
|
||||||
c << opts
|
c << opts
|
||||||
|
|
||||||
|
@ -254,19 +254,6 @@ module Vagrant
|
||||||
def self.reset!
|
def self.reset!
|
||||||
instance_variables.each(&method(:remove_instance_variable))
|
instance_variables.each(&method(:remove_instance_variable))
|
||||||
end
|
end
|
||||||
|
|
||||||
# @private
|
|
||||||
# This is a helper method that provides the PowerShell command to resize
|
|
||||||
# the "console" to prevent output wrapping or truncating. An environment
|
|
||||||
# variable guard is provided to disable the behavior in cases where it
|
|
||||||
# may cause unexpected results (VAGRANT_POWERSHELL_RESIZE_DISABLE)
|
|
||||||
def self.resize_console
|
|
||||||
if ENV["VAGRANT_POWERSHELL_RESIZE_DISABLE"]
|
|
||||||
""
|
|
||||||
else
|
|
||||||
"$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(512,50); "
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -120,14 +120,6 @@ describe Vagrant::Util::PowerShell do
|
||||||
described_class.execute("custom-command")
|
described_class.execute("custom-command")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should automatically include console resize" do
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
|
||||||
expect(comm.to_s).to include("BufferSize")
|
|
||||||
end
|
|
||||||
described_class.execute("custom-command")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should accept custom environment" do
|
it "should accept custom environment" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
||||||
|
@ -173,15 +165,6 @@ describe Vagrant::Util::PowerShell do
|
||||||
described_class.execute_cmd("custom-command")
|
described_class.execute_cmd("custom-command")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should automatically include console resize" do
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
|
||||||
expect(comm.to_s).to include("BufferSize")
|
|
||||||
result
|
|
||||||
end
|
|
||||||
described_class.execute_cmd("custom-command")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should accept custom environment" do
|
it "should accept custom environment" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
||||||
|
@ -245,15 +228,6 @@ describe Vagrant::Util::PowerShell do
|
||||||
described_class.execute_inline("custom-command")
|
described_class.execute_inline("custom-command")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should automatically include console resize" do
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
|
||||||
expect(comm.to_s).to include("BufferSize")
|
|
||||||
result
|
|
||||||
end
|
|
||||||
described_class.execute_inline("custom-command")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should accept custom environment" do
|
it "should accept custom environment" do
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
expect(Vagrant::Util::Subprocess).to receive(:execute) do |*args|
|
||||||
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
comm = args.detect{|s| s.to_s.include?("custom-command") }
|
||||||
|
@ -299,16 +273,4 @@ describe Vagrant::Util::PowerShell do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".resize_console" do
|
|
||||||
it "should return command string" do
|
|
||||||
expect(described_class.resize_console).to include("BufferSize")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should return empty string when disabled" do
|
|
||||||
with_temp_env("VAGRANT_POWERSHELL_RESIZE_DISABLE" => "1") do
|
|
||||||
expect(described_class.resize_console).to be_empty
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue