Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 453f5f2

Browse files
committed
Sort keys in all JSON dumps
1 parent 455f9a6 commit 453f5f2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

importmap/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LockfileSchema(Schema):
3333

3434

3535
def hash_for_data(data):
36-
return hashlib.md5(json.dumps(data).encode("utf-8")).hexdigest()
36+
return hashlib.md5(json.dumps(data, sort_keys=True).encode("utf-8")).hexdigest()
3737

3838

3939
class Importmap:
@@ -102,7 +102,7 @@ def load_lockfile(self):
102102

103103
def save_lockfile(self, lockfile):
104104
with open(self.lock_filename, "w+") as f:
105-
json.dump(lockfile, f, indent=2)
105+
json.dump(lockfile, f, indent=2, sort_keys=True)
106106

107107
def delete_lockfile(self):
108108
if os.path.exists(self.lock_filename):

importmap/templatetags/importmap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def importmap_scripts():
1414
importmap.load()
1515

1616
if settings.DEBUG:
17-
return {"importmap": json.dumps(importmap.map_dev, indent=2)}
17+
return {"importmap": json.dumps(importmap.map_dev, indent=2, sort_keys=True)}
1818
else:
19-
return {"importmap": json.dumps(importmap.map)}
19+
return {"importmap": json.dumps(importmap.map, sort_keys=True)}

test_project/importmap.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
2-
"config_hash": "09d6237cdd891aad07de60f54689d130",
3-
"importmap": {
2+
"importmap_dev": {
43
"imports": {
5-
"react": "https://ga.jspm.io/npm:[email protected]/index.js"
4+
"react": "https://ga.jspm.io/npm:[email protected]/dev.index.js"
65
},
76
"scopes": {
87
"https://ga.jspm.io/": {
98
"object-assign": "https://ga.jspm.io/npm:[email protected]/index.js"
109
}
1110
}
1211
},
13-
"importmap_dev": {
12+
"importmap": {
1413
"imports": {
15-
"react": "https://ga.jspm.io/npm:[email protected]/dev.index.js"
14+
"react": "https://ga.jspm.io/npm:[email protected]/index.js"
1615
},
1716
"scopes": {
1817
"https://ga.jspm.io/": {
1918
"object-assign": "https://ga.jspm.io/npm:[email protected]/index.js"
2019
}
2120
}
22-
}
21+
},
22+
"config_hash": "09d6237cdd891aad07de60f54689d130"
2323
}

0 commit comments

Comments
 (0)