Sha256: d3a9786b42045d296f748f9faf4e2d0acb61f71d0e0f3b0fd57591d89b1bdde8

Contents?: true

Size: 1.37 KB

Versions: 47

Compression:

Stored size: 1.37 KB

Contents

module Vagrant
  module Action
    module General
      class PackageSetupFiles
        def initialize(app, env)
          @app = app

          env["package.include"] ||= []
          env["package.vagrantfile"] ||= nil
        end

        def call(env)
          files = {}
          env["package.include"].each do |file|
            source = Pathname.new(file)
            dest   = nil

            # If the source is relative then we add the file as-is to the include
            # directory. Otherwise, we copy only the file into the root of the
            # include directory. Kind of strange, but seems to match what people
            # expect based on history.
            if source.relative?
              dest = source
            else
              dest = source.basename
            end

            # Assign the mapping
            files[file] = dest
          end

          if env["package.vagrantfile"]
            # Vagrantfiles are treated special and mapped to a specific file
            files[env["package.vagrantfile"]] = "_Vagrantfile"
          end

          # Verify the mapping
          files.each do |from, _|
            raise Vagrant::Errors::PackageIncludeMissing,
                  file: from if !File.exist?(from)
          end

          # Save the mapping
          env["package.files"] = files

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

47 entries across 43 versions & 5 rubygems

Version Path
vagrant-unbundled-2.3.6.0 lib/vagrant/action/general/package_setup_files.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.3.3.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.3.2.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.19.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.18.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.16.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.14.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.10.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.9.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.8.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.7.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.6.2 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.6.1 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.6.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.5.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.4.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.3.0 lib/vagrant/action/general/package_setup_files.rb
vagrant-unbundled-2.2.2.0 lib/vagrant/action/general/package_setup_files.rb