Skip to content

Commit bc6b2cb

Browse files
committed
Swap to use new createHashHexSync method from eleventy-utils
1 parent 2031603 commit bc6b2cb

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"prettier": "^3.5.3"
4646
},
4747
"dependencies": {
48-
"@11ty/eleventy-utils": "^2.0.1",
48+
"@11ty/eleventy-utils": "^2.0.7",
4949
"@rgrove/parse-xml": "^4.2.0",
5050
"debug": "^4.4.0",
5151
"flatted": "^3.3.3",

src/AssetCache.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const fs = require("node:fs");
22
const path = require("node:path");
3-
const { createHash } = require("node:crypto");
4-
const { DateCompare } = require("@11ty/eleventy-utils");
3+
const { DateCompare, createHashHexSync } = require("@11ty/eleventy-utils");
54

65
const FileCache = require("./FileCache.js");
76
const Sources = require("./Sources.js");
@@ -88,22 +87,12 @@ class AssetCache {
8887
// Defult hashLength also set in global options, duplicated here for tests
8988
// v5.0+ key can be Array or literal
9089
static getHash(key, hashLength = 30) {
91-
let hash = createHash("sha256");
92-
9390
if (!Array.isArray(key)) {
9491
key = [key];
9592
}
9693

97-
for (let k of key) {
98-
k = "" + k;
99-
if (k) {
100-
hash.update(k);
101-
} else {
102-
throw new Error(`Not able to convert asset key (${k}) to string.`);
103-
}
104-
}
105-
106-
return ("" + hash.digest("hex")).slice(0, hashLength);
94+
let result = createHashHexSync(...key);
95+
return result.slice(0, hashLength);
10796
}
10897

10998
get source() {

0 commit comments

Comments
 (0)