Sha256: 55dd18c4da0bc4a3ce85f9342fa9c0656b7df060045fe9ed9e80bb079923fe1e

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

require "English"

module VagrantHelpers
  extend self

  class VagrantSSHCommandError < RuntimeError; end

  at_exit do
    if ENV["KEEP_RUNNING"]
      puts "Vagrant vm will be left up because KEEP_RUNNING is set."
      puts "Rerun without KEEP_RUNNING set to cleanup the vm."
    else
      vagrant_cli_command("destroy -f")
    end
  end

  def vagrant_cli_command(command)
    puts "[vagrant] #{command}"
    Dir.chdir(VAGRANT_ROOT) do
      `#{VAGRANT_BIN} #{command} 2>&1`.split("\n").each do |line|
        puts "[vagrant] #{line}"
      end
    end
    $CHILD_STATUS
  end

  def run_vagrant_command(command)
    if (status = vagrant_cli_command("ssh -c #{command.inspect}")).success?
      true
    else
      raise VagrantSSHCommandError, status
    end
  end
end

World(VagrantHelpers)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
capistrano-3.6.1 features/support/vagrant_helpers.rb
capistrano-3.6.0 features/support/vagrant_helpers.rb
capistrano-3.5.0 features/support/vagrant_helpers.rb