From dc9103623a204a5d3ff0ab697804ce8b97c4679a Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Sat, 15 Jun 2019 14:17:14 +0100 Subject: [PATCH] Encode keys in sorted order This reduces diffs, which is always good! --- src/Niv/Cli.hs | 2 +- tests/expected/niv-init.json | 40 ++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Niv/Cli.hs b/src/Niv/Cli.hs index f30b311..1183f10 100644 --- a/src/Niv/Cli.hs +++ b/src/Niv/Cli.hs @@ -428,7 +428,7 @@ decodeFileStrict = fmap Aeson.decodeStrict . B.readFile encodeFile :: (ToJSON a) => FilePath -> a -> IO () encodeFile fp = L.writeFile fp . AesonPretty.encodePretty' config where - config = AesonPretty.defConfig { AesonPretty.confTrailingNewline = True } + config = AesonPretty.defConfig { AesonPretty.confTrailingNewline = True, AesonPretty.confCompare = compare } --- HashMap diff --git a/tests/expected/niv-init.json b/tests/expected/niv-init.json index 13c149d..0dc14b8 100644 --- a/tests/expected/niv-init.json +++ b/tests/expected/niv-init.json @@ -1,26 +1,26 @@ { - "nixpkgs": { - "homepage": null, - "url": "http://localhost:3333/NixOS/nixpkgs-channels/archive/571b40d3f50466d3e91c1e609d372de96d782793.tar.gz", - "owner": "NixOS", - "branch": "nixos-18.09", - "url_template": "http://localhost:3333///archive/.tar.gz", - "repo": "nixpkgs-channels", - "type": "tarball", - "sha256": "18hlxki1hbimvm1jagcf7dy5km1iakr1px472cb05y9602py7f6g", - "description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels", - "rev": "571b40d3f50466d3e91c1e609d372de96d782793" - }, "niv": { - "homepage": "https://github.com/nmattia/niv", - "url": "http://localhost:3333/nmattia/niv/archive/a489b65a5c3a29983701069d1ce395b23d9bde64.tar.gz", - "owner": "nmattia", "branch": "master", - "url_template": "http://localhost:3333///archive/.tar.gz", - "repo": "niv", - "type": "tarball", - "sha256": "18hx0pg48xh306gwz9wja8fcyl8isfkv3ja7453yj3hmy72b6scp", "description": "Easy dependency management for Nix projects", - "rev": "a489b65a5c3a29983701069d1ce395b23d9bde64" + "homepage": "https://github.com/nmattia/niv", + "owner": "nmattia", + "repo": "niv", + "rev": "a489b65a5c3a29983701069d1ce395b23d9bde64", + "sha256": "18hx0pg48xh306gwz9wja8fcyl8isfkv3ja7453yj3hmy72b6scp", + "type": "tarball", + "url": "http://localhost:3333/nmattia/niv/archive/a489b65a5c3a29983701069d1ce395b23d9bde64.tar.gz", + "url_template": "http://localhost:3333///archive/.tar.gz" + }, + "nixpkgs": { + "branch": "nixos-18.09", + "description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels", + "homepage": null, + "owner": "NixOS", + "repo": "nixpkgs-channels", + "rev": "571b40d3f50466d3e91c1e609d372de96d782793", + "sha256": "18hlxki1hbimvm1jagcf7dy5km1iakr1px472cb05y9602py7f6g", + "type": "tarball", + "url": "http://localhost:3333/NixOS/nixpkgs-channels/archive/571b40d3f50466d3e91c1e609d372de96d782793.tar.gz", + "url_template": "http://localhost:3333///archive/.tar.gz" } }