Open dwkerwin opened 7 years ago
The first commit didn't completely solve the problem. Line terminations were right but it was still flattening the hosts to a single line. In the use case where you have multiple (> 10) hostnames which you want to all point to a single IP (typically 127.0.0.1), this exceeds the Windows limit of 9 per line. This change prevents this flattening for Windows while continuing to be idempotent, preventing duplicate entries by hostname rather than IP address.
It looks like the Travis CI errors are unrelated to my changes. Please let me know if this is not the case or how I could help.
I've been using this for a while, and even though on Windows when you view the hosts file everything appears to be on one line, it has been working. I recently noticed that if you have a lot of host aliases on the same machine the ones at the end aren't honored, and then discovered that there is a limit on Windows of 9 aliases per line. So this small fix uses the environment specific newline terminator, so "\r\n" for Windows and "\n" for all other environments.