Class: VagrantPlugins::WinAzure::Action::PowerShellRun

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-azure/action/powershell_run.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PowerShellRun

Returns a new instance of PowerShellRun.



5
6
7
8
# File 'lib/vagrant-azure/action/powershell_run.rb', line 5

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant_azure::action::powershell_run_command')
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-azure/action/powershell_run.rb', line 10

def call(env)

  if env[:machine].communicate.ready?
    env[:machine].ui.detail("PowerShell Executing: #{env[:powershell_command]}")
    env[:powershell_command_exit_status] = env[:machine].communicate.execute(env[:powershell_command]) do |type, stream|
      if type == :stdout
        env[:machine].ui.success(stream) unless (stream || '').chomp.empty?
      else
        env[:machine].ui.error(stream) unless (stream || '').chomp.empty?
      end
    end
  end

  @app.call(env)
end