Merge pull request #38 from mosaicxm/feature/current-vagrantfile-updates
only remove lines for the current vagrantfile
This commit is contained in:
		
						commit
						58d47cfb8f
					
				| 
						 | 
					@ -44,6 +44,7 @@ module VagrantPlugins
 | 
				
			||||||
      def update_file(file)
 | 
					      def update_file(file)
 | 
				
			||||||
        # build array of host file entries from Vagrant configuration
 | 
					        # build array of host file entries from Vagrant configuration
 | 
				
			||||||
        entries = []
 | 
					        entries = []
 | 
				
			||||||
 | 
					        ids = []
 | 
				
			||||||
        get_machines.each do |name, p|
 | 
					        get_machines.each do |name, p|
 | 
				
			||||||
          if @provider == p
 | 
					          if @provider == p
 | 
				
			||||||
            machine = @global_env.machine(name, p)
 | 
					            machine = @global_env.machine(name, p)
 | 
				
			||||||
| 
						 | 
					@ -52,6 +53,7 @@ module VagrantPlugins
 | 
				
			||||||
            ip = get_ip_address(machine)
 | 
					            ip = get_ip_address(machine)
 | 
				
			||||||
            aliases = machine.config.hostmanager.aliases.join(' ').chomp
 | 
					            aliases = machine.config.hostmanager.aliases.join(' ').chomp
 | 
				
			||||||
            entries <<  "#{ip}\t#{host} #{aliases}\t# VAGRANT ID: #{id}\n"
 | 
					            entries <<  "#{ip}\t#{host} #{aliases}\t# VAGRANT ID: #{id}\n"
 | 
				
			||||||
 | 
					            ids << id unless ids.include?(id)
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,7 +61,7 @@ module VagrantPlugins
 | 
				
			||||||
        begin
 | 
					        begin
 | 
				
			||||||
          # copy each line not managed by Vagrant
 | 
					          # copy each line not managed by Vagrant
 | 
				
			||||||
          File.open(file).each_line do |line|
 | 
					          File.open(file).each_line do |line|
 | 
				
			||||||
            tmp_file << line unless line =~ /# VAGRANT ID:/
 | 
					            tmp_file << line unless ids.any? { |id| line =~ /# VAGRANT ID: #{id}/ }
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          # write a line for each Vagrant-managed entry
 | 
					          # write a line for each Vagrant-managed entry
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue