Skip to content

Commit

Permalink
Merge pull request #12 from grimsa/bugfix/11
Browse files Browse the repository at this point in the history
#11: Format snapshots using LF only regardless of platform
  • Loading branch information
andrebonna authored Feb 12, 2019
2 parents 4479e51 + d4f57f6 commit d34172f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/io/github/jsonSnapshot/SnapshotMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.PrettyPrinter;
import com.fasterxml.jackson.core.util.DefaultIndenter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter.Indenter;
import com.fasterxml.jackson.core.util.Separators;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand Down Expand Up @@ -97,7 +99,7 @@ static Function<Object, String> defaultJsonFunction() {

ObjectMapper objectMapper = buildObjectMapper();

DefaultPrettyPrinter pp = buildDefaultPrettyPrinter();
PrettyPrinter pp = buildDefaultPrettyPrinter();

return (object) -> {
try {
Expand All @@ -108,7 +110,7 @@ static Function<Object, String> defaultJsonFunction() {
};
}

private static DefaultPrettyPrinter buildDefaultPrettyPrinter() {
private static PrettyPrinter buildDefaultPrettyPrinter() {
DefaultPrettyPrinter pp = new DefaultPrettyPrinter(""){
@Override
public DefaultPrettyPrinter withSeparators(Separators separators) {
Expand All @@ -117,7 +119,9 @@ public DefaultPrettyPrinter withSeparators(Separators separators) {
return this;
}
};
pp.indentArraysWith(DefaultIndenter.SYSTEM_LINEFEED_INSTANCE);
Indenter lfOnlyIndenter = new DefaultIndenter(" ", "\n");
pp.indentArraysWith(lfOnlyIndenter);
pp.indentObjectsWith(lfOnlyIndenter);
return pp;
}

Expand Down

0 comments on commit d34172f

Please sign in to comment.