Commit 4f8f38c3 authored by Volker Hilsheimer's avatar Volker Hilsheimer
Browse files

More flexible shared_folder syntax

Can be a list of mappings, or an array of paths in a hash as well.
parent 5d19fa2c
......@@ -78,31 +78,35 @@ def share_folders(box, machine, shares)
default_shares = {}
shares.each do |share|
next if share.nil?
# each entry could be just alpha; or alpha => beta or host => alpha; guest => beta
host = share["host"] || share.first[0]
guest = share["guest"] || share.first[1] || host
host = expand_env(host)
host = "." if host == $PWD # this prevents duplicate PWD sharing from vagrant
guest = expand_env(guest)
if guest.nil? || host.nil?
STDERR.puts "==> #{machine['name']}: Unexpanded environment variable in '#{share}' - skipping share"
next
end
if !box.nil? && box.vm.guest == :windows
guest = guest.gsub("/C:\\", "C:\\")
guest = guest.gsub("/", "\\\\")
end
share_type = share["type"]
share.delete("type")
share = share["paths"] if share["paths"]
share.each do |host, guest|
# each entry could be just alpha; or alpha => beta or host => alpha; guest => beta
guest ||= host
host = expand_env(host)
host = "." if host == $PWD # this prevents duplicate PWD sharing from vagrant
guest = expand_env(guest)
if guest.nil? || host.nil?
STDERR.puts "==> #{machine['name']}: Unexpanded environment variable in '#{share}' - skipping share"
next
end
if !box.nil? && box.vm.guest == :windows
guest = guest.gsub("/C:\\", "C:\\")
guest = guest.gsub("/", "\\\\")
end
case share["type"]
when 'mutagen'
mutagen_share(box, { "paths" => { host => guest } }, machine)
when 'rsync'
guest = adjust_guest_path(guest, box)
host = host.gsub("~", $HOME)
box.vm.synced_folder host, guest, type: :rsync
box.minicoin.fs_mappings.merge!({host => guest})
else
default_shares[host] = guest
case share_type
when 'mutagen'
mutagen_share(box, { "paths" => { host => guest } }, machine)
when 'rsync'
guest = adjust_guest_path(guest, box)
host = host.gsub("~", $HOME)
box.vm.synced_folder host, guest, type: :rsync
box.minicoin.fs_mappings.merge!({host => guest})
else
default_shares[host] = guest
end
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment