Skip to content

Commit

Permalink
Updates gatsby source faker to use createContentDigest helper
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasassisrosa committed Jan 22, 2019
1 parent 4fc1d45 commit 413b093
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-source-faker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"license": "MIT",
"main": "index.js",
"peerDependencies": {
"gatsby": ">2.0.0-alpha"
"gatsby": ">=2.0.15"
},
"repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-faker",
"scripts": {
Expand Down
9 changes: 2 additions & 7 deletions packages/gatsby-source-faker/src/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const faker = require(`faker`)
const crypto = require(`crypto`)

exports.sourceNodes = ({ actions, createNodeId }, pluginOptions) => {
exports.sourceNodes = ({ actions, createNodeId, createContentDigest }, pluginOptions) => {
const { createNode } = actions
const { schema, count, type } = pluginOptions
for (let i = 0; i < count; i++) {
Expand All @@ -14,18 +13,14 @@ exports.sourceNodes = ({ actions, createNodeId }, pluginOptions) => {
item[schemaKey][schemaItem] = faker[schemaKey][schemaItem]()
})
})
const contentDigest = crypto
.createHash(`md5`)
.update(JSON.stringify(item))
.digest(`hex`)

const nodeBase = {
id: createNodeId(JSON.stringify(faker.random.number())),
parent: null,
children: [],
internal: {
type,
contentDigest,
contentDigest: createContentDigest(item),
},
}
createNode(Object.assign({}, nodeBase, item))
Expand Down

0 comments on commit 413b093

Please sign in to comment.