Skip to content

Commit

Permalink
chore(gastby-plugin-sharp): Use createContentDigest helper (#18139)
Browse files Browse the repository at this point in the history
* chore(gastby-plugin-sharp): Use createContentDigest helper

Updates the plugin to use the help instead of manually handling the
crypto work. Functions were added to the pass the helper down into the
process-file module, similar to how setBoundActionCreators was working
but with an extra level.

Relates to #8805

* chore(gastby-plugin-sharp): Use createContentDigest from core-utils
  • Loading branch information
jbutz authored and GatsbyJS Bot committed Oct 16, 2019
1 parent 8983585 commit 27302a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"license": "MIT",
"main": "index.js",
"peerDependencies": {
"gatsby": "^2.0.0"
"gatsby": ">2.0.15"
},
"repository": {
"type": "git",
Expand Down
8 changes: 2 additions & 6 deletions packages/gatsby-plugin-sharp/src/process-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const imageminMozjpeg = require(`imagemin-mozjpeg`)
const imageminPngquant = require(`imagemin-pngquant`)
const imageminWebp = require(`imagemin-webp`)
const _ = require(`lodash`)
const crypto = require(`crypto`)
const { cpuCoreCount } = require(`gatsby-core-utils`)
const { cpuCoreCount, createContentDigest } = require(`gatsby-core-utils`)
const got = require(`got`)

// Try to enable the use of SIMD instructions. Seems to provide a smallish
Expand Down Expand Up @@ -261,10 +260,7 @@ exports.createArgsDigest = args => {
return argsWhitelist.includes(key)
})

const argsDigest = crypto
.createHash(`md5`)
.update(JSON.stringify(sortKeys(filtered)))
.digest(`hex`)
const argsDigest = createContentDigest(sortKeys(filtered))

const argsDigestShort = argsDigest.substr(argsDigest.length - 5)

Expand Down

0 comments on commit 27302a1

Please sign in to comment.