Skip to content

Commit d34172f

Browse files
authored
Merge pull request #12 from grimsa/bugfix/11
#11: Format snapshots using LF only regardless of platform
2 parents 4479e51 + d4f57f6 commit d34172f

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;
@@ -97,7 +99,7 @@ static Function<Object, String> defaultJsonFunction() {
9799

98100
ObjectMapper objectMapper = buildObjectMapper();
99101

100-
DefaultPrettyPrinter pp = buildDefaultPrettyPrinter();
102+
PrettyPrinter pp = buildDefaultPrettyPrinter();
101103

102104
return (object) -> {
103105
try {
@@ -108,7 +110,7 @@ static Function<Object, String> defaultJsonFunction() {
108110
};
109111
}
110112

111-
private static DefaultPrettyPrinter buildDefaultPrettyPrinter() {
113+
private static PrettyPrinter buildDefaultPrettyPrinter() {
112114
DefaultPrettyPrinter pp = new DefaultPrettyPrinter(""){
113115
@Override
114116
public DefaultPrettyPrinter withSeparators(Separators separators) {
@@ -117,7 +119,9 @@ public DefaultPrettyPrinter withSeparators(Separators separators) {
117119
return this;
118120
}
119121
};
120-
pp.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
122+
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n");
123+
pp.indentArraysWith(lfOnlyIndenter);
124+
pp.indentObjectsWith(lfOnlyIndenter);
121125
return pp;
122126
}
123127

0 commit comments

Comments
 (0)