From 3e5eaa05c68015c1ecbfbca717fc79f44d993b75 Mon Sep 17 00:00:00 2001 From: Seb Patane Date: Fri, 13 Feb 2015 15:39:47 +1000 Subject: [PATCH 1/2] Use windows line endings for windows hosts file --- libraries/manipulator.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/manipulator.rb b/libraries/manipulator.rb index 6afc0476..119eca1f 100644 --- a/libraries/manipulator.rb +++ b/libraries/manipulator.rb @@ -208,7 +208,9 @@ def new_content entries = hostsfile_header entries += unique_entries.map(&:to_line) entries << '' - entries.join("\n") + line_ending = "\n" + line_ending = "\r\n" if node['platform_family'] == 'windows' + entries.join(line_ending) end # The current sha of the system hostsfile. From 1ad9b83719d24e907a6efb532c707bb52fadd1d0 Mon Sep 17 00:00:00 2001 From: Seb Patane Date: Sun, 21 Jun 2015 21:43:32 +1000 Subject: [PATCH 2/2] nicer syntax --- libraries/manipulator.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/manipulator.rb b/libraries/manipulator.rb index 119eca1f..8c2ad2a6 100644 --- a/libraries/manipulator.rb +++ b/libraries/manipulator.rb @@ -208,8 +208,7 @@ def new_content entries = hostsfile_header entries += unique_entries.map(&:to_line) entries << '' - line_ending = "\n" - line_ending = "\r\n" if node['platform_family'] == 'windows' + line_ending = node['platform_family'] == 'windows' ? "\r\n" : "\n" entries.join(line_ending) end