Skip to content

Commit d4f57f6

Browse files
committed
Format snapshots using LF only regardless of platform
1 parent 445e291 commit d4f57f6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import com.fasterxml.jackson.annotation.JsonAutoDetect;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.core.PrettyPrinter;
56
import com.fasterxml.jackson.core.util.DefaultIndenter;
67
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
8+
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Indenter;
79
import com.fasterxml.jackson.core.util.Separators;
810
import com.fasterxml.jackson.databind.ObjectMapper;
911
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -99,7 +101,7 @@ static Function<Object, String> defaultJsonFunction() {
99101

100102
ObjectMapper objectMapper = buildObjectMapper();
101103

102-
DefaultPrettyPrinter pp = buildDefaultPrettyPrinter();
104+
PrettyPrinter pp = buildDefaultPrettyPrinter();
103105

104106
return (object) -> {
105107
try {
@@ -110,7 +112,7 @@ static Function<Object, String> defaultJsonFunction() {
110112
};
111113
}
112114

113-
private static DefaultPrettyPrinter buildDefaultPrettyPrinter() {
115+
private static PrettyPrinter buildDefaultPrettyPrinter() {
114116
DefaultPrettyPrinter pp = new DefaultPrettyPrinter(""){
115117
@Override
116118
public DefaultPrettyPrinter withSeparators(Separators separators) {
@@ -119,7 +121,9 @@ public DefaultPrettyPrinter withSeparators(Separators separators) {
119121
return this;
120122
}
121123
};
122-
pp.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
124+
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n");
125+
pp.indentArraysWith(lfOnlyIndenter);
126+
pp.indentObjectsWith(lfOnlyIndenter);
123127
return pp;
124128
}
125129

0 commit comments

Comments
 (0)