Skip to content

Commit

Permalink
chore(gastby-transformer-sqip): Use createContentDigest helper (#18534)
Browse files Browse the repository at this point in the history
* chore(gastby-transformer-sqip): Use createContentDigest helper

Updates the plugin to use the help instead of manually handling the
crypto work.

* chore(gatsby-transformer-sqip): Remove unnecessary await keyword

The `await` keyword was causing Jest to issue a warning because
`describe` functions shouldn't be returning Promises.
  • Loading branch information
jbutz authored and GatsbyJS Bot committed Oct 14, 2019
1 parent 84fa85d commit aafabc6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ afterEach(() => {
writeFile.mockClear()
})

describe(`gatsby-transformer-sqip`, async () => {
describe(`gatsby-transformer-sqip`, () => {
const absolutePath = resolve(
__dirname,
`images`,
Expand Down
7 changes: 2 additions & 5 deletions packages/gatsby-transformer-sqip/src/generate-sqip.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const crypto = require(`crypto`)
const { resolve, parse } = require(`path`)

const Debug = require(`debug`)
const { exists, readFile, writeFile } = require(`fs-extra`)
const svgToMiniDataURI = require(`mini-svg-data-uri`)
const PQueue = require(`p-queue`)
const sqip = require(`sqip`)
const { createContentDigest } = require(`gatsby-core-utils`)

const queue = new PQueue({ concurrency: 1 })
const debug = Debug(`gatsby-transformer-sqip`)
Expand Down Expand Up @@ -36,10 +36,7 @@ module.exports = async function generateSqip(options) {
mode,
}

const optionsHash = crypto
.createHash(`md5`)
.update(JSON.stringify(sqipOptions))
.digest(`hex`)
const optionsHash = createContentDigest(sqipOptions)

const cacheKey = `${contentDigest}-${optionsHash}`
const cachePath = resolve(cacheDir, `${contentDigest}-${optionsHash}.svg`)
Expand Down

0 comments on commit aafabc6

Please sign in to comment.