Sha256: af5b1d3bdca5b5a58fc4d3f871f92641e53f1e4d2162348bc148cf6be10d0125

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

module VagrantNoRequireTTY
  class Action
    def initialize(app, env)
      @app = app
      @env = env
      @machine = env[:machine]
      @set = false
    end

    def call(env)
      # So nice, we call it twice.
      disable_requiretty!

      @app.call(env)

      disable_requiretty!
    end

    private

    def disable_requiretty!
      if supports_requiretty?(@machine) && (not @set)
        @machine.guest.capability(:norequiretty)
        @set = true
      end
    end

    def supports_requiretty?(machine)
      machine.communicate.ready? && machine.guest.capability?(:norequiretty)
    rescue Vagrant::Errors::VagrantError
      # WinRM will raise an error if the VM isn't running instead of
      # returning false.
      false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-norequiretty-0.0.2 lib/vagrant-norequiretty/action.rb
vagrant-norequiretty-0.0.1 lib/vagrant-norequiretty/action.rb