Sha256: 4f47430e631a28fbe1b4c153bf368cee1c179b191b95297e2d3fd91360dfd879
Contents?: true
Size: 697 Bytes
Versions: 2
Compression:
Stored size: 697 Bytes
Contents
# Provide a base class for syncing hosts entries on Windows systems. class VagrantHosts::Cap::SyncHosts::Windows < VagrantHosts::Cap::SyncHosts::Base def update_hosts host_entries = [] all_hosts.each do |(address, aliases)| aliases.each do |name| host_entries << "#{address} #{name}" end end script = [] script << '$HostsLocation = "$env:windir\\System32\\drivers\\etc\\hosts";' host_entries.each do |entry| script << "\$HostEntry = \"#{entry}\"" script << "if (!((gc \$HostsLocation) -contains $HostEntry)) { Add-Content -Path $HostsLocation -Value $HostEntry; }" end @machine.communicate.sudo(script.join("\r\n")) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-hosts-2.0.0 | lib/vagrant-hosts/cap/sync_hosts/windows.rb |
vagrant-hosts-2.0.0rc1 | lib/vagrant-hosts/cap/sync_hosts/windows.rb |