provisioners/file: expand destination path if capable

This commit is contained in:
Teemu Matilainen 2014-02-01 01:23:09 -03:00
parent 9771c8bd52
commit b52958bfb6
1 changed files with 16 additions and 3 deletions

View File

@ -3,12 +3,25 @@ module VagrantPlugins
class Provisioner < Vagrant.plugin("2", :provisioner) class Provisioner < Vagrant.plugin("2", :provisioner)
def provision def provision
@machine.communicate.tap do |comm| @machine.communicate.tap do |comm|
destination = expand_guest_path(config.destination)
# Make sure the remote path exists # Make sure the remote path exists
command = "mkdir -p %s" % File.dirname(config.destination) command = "mkdir -p %s" % File.dirname(destination)
comm.execute(command) comm.execute(command)
# now upload the file # now upload the file
comm.upload(File.expand_path(config.source), config.destination) comm.upload(File.expand_path(config.source), destination)
end
end
private
# Expand the guest path if the guest has the capability
def expand_guest_path(destination)
if machine.guest.capability?(:shell_expand_guest_path)
machine.guest.capability(:shell_expand_guest_path, destination)
else
destination
end end
end end
end end