Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convert to WindowsLineBreaks

  • Loading branch information...
commit e64e3af9da5f12a61602145f7b2ba4cc85158f6d 1 parent c24348b
Steffen Forkmann forki authored
Showing with 20 additions and 0 deletions.
  1. +1 −0  changelog.markdown
  2. +19 −0 src/app/FakeLib/StringHelper.fs
1  changelog.markdown
View
@@ -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
19 src/app/FakeLib/StringHelper.fs
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.