Skip to content

Commit 1717fa9

Browse files
committed
Merge pull request #138 from rprouse/issue/136
If the OS is windows, convert line endings from LF to CRLF when saving
2 parents 83ca2fc + 5c6d2d8 commit 1717fa9

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

user/item.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"io/ioutil"
55
"os"
66
"path/filepath"
7+
"runtime"
8+
"strings"
79

810
"github.com/exercism/cli/api"
911
)
@@ -59,6 +61,10 @@ func (it *Item) Save() error {
5961
it.isUpdated = true
6062
}
6163

64+
if runtime.GOOS == "windows" {
65+
text = strings.Replace(text, "\n", "\r\n", -1)
66+
}
67+
6268
if err := ioutil.WriteFile(file, []byte(text), 0644); err != nil {
6369
return err
6470
}

0 commit comments

Comments
 (0)