Permalink
Browse files

Convert to WindowsLineBreaks

  • Loading branch information...
1 parent c24348b commit e64e3af9da5f12a61602145f7b2ba4cc85158f6d @forki forki committed Jun 24, 2011
Showing with 20 additions and 0 deletions.
  1. +1 −0 changelog.markdown
  2. +19 −0 src/app/FakeLib/StringHelper.fs
View
1 changelog.markdown
@@ -1,6 +1,7 @@
## 1.58.0.0
* ReplaceAssemblyInfoVersions task allows to replace version info in AssemblyVersion-files
+* New task ConvertFileToWindowsLineBreaks
## 1.56.10.0
View
19 src/app/FakeLib/StringHelper.fs
@@ -56,9 +56,28 @@ let inline separated delimiter items = String.Join(delimiter, Array.ofSeq items)
/// Reads a file as one text
let ReadFileAsString file = File.ReadAllText(file,Encoding.Default)
+/// Replaces the text in the given file
+let ReplaceInFile replaceF fileName =
+ fileName
+ |> ReadFileAsString
+ |> replaceF
+ |> ReplaceFile fileName
+
/// Replaces the given pattern in the given text with the replacement
let inline replace (pattern:string) replacement (text:string) = text.Replace(pattern,replacement)
+let LinuxLineBreaks = "\n"
+let WindowsLineBreaks = "\r\n"
+let MacLineBreaks = "\r"
+
+let ConvertTextToWindowsLineBreaks text =
+ text
+ |> replace WindowsLineBreaks LinuxLineBreaks
+ |> replace MacLineBreaks LinuxLineBreaks
+ |> replace LinuxLineBreaks WindowsLineBreaks
+
+let ConvertFileToWindowsLineBreaks fileName = ReplaceInFile ConvertTextToWindowsLineBreaks fileName
+
let replaceFirst (pattern: string) replacement (text: string) =
let pos = text.IndexOf pattern
if pos < 0

0 comments on commit e64e3af

Please sign in to comment.