diff --git a/package.json b/package.json index 67f842e7da265..317dc597b5406 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ ], "license": "MIT", "peerDependencies": { - "gatsby": "^2.0.0" + "gatsby": "^2.0.15" }, "repository": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem", "scripts": { diff --git a/src/create-file-node.js b/src/create-file-node.js index 3db6fcadd8483..a11add1b72cf4 100644 --- a/src/create-file-node.js +++ b/src/create-file-node.js @@ -5,7 +5,7 @@ const mime = require(`mime`) const prettyBytes = require(`pretty-bytes`) const md5File = require(`bluebird`).promisify(require(`md5-file`)) -const crypto = require(`crypto`) +const { createContentDigest } = require(`gatsby/utils`) exports.createFileNode = async ( pathToFile, @@ -27,12 +27,10 @@ exports.createFileNode = async ( const stats = await fs.stat(slashedFile.absolutePath) let internal if (stats.isDirectory()) { - const contentDigest = crypto - .createHash(`md5`) - .update( - JSON.stringify({ stats: stats, absolutePath: slashedFile.absolutePath }) - ) - .digest(`hex`) + const contentDigest = createContentDigest({ + stats: stats, + absolutePath: slashedFile.absolutePath, + }) internal = { contentDigest, type: `Directory`, diff --git a/src/create-remote-file-node.js b/src/create-remote-file-node.js index a7be7d1431868..c4332e4c87f0c 100644 --- a/src/create-remote-file-node.js +++ b/src/create-remote-file-node.js @@ -1,6 +1,6 @@ const fs = require(`fs-extra`) const got = require(`got`) -const crypto = require(`crypto`) +const { createContentDigest } = require(`gatsby/utils`) const path = require(`path`) const { isWebUri } = require(`valid-url`) const Queue = require(`better-queue`) @@ -53,24 +53,6 @@ const bar = new ProgressBar( * @param {Auth} [options.auth] */ -/********* - * utils * - *********/ - -/** - * createHash - * -- - * - * Create an md5 hash of the given str - * @param {Stringq} str - * @return {String} - */ -const createHash = str => - crypto - .createHash(`md5`) - .update(str) - .digest(`hex`) - const CACHE_DIR = `.cache` const FS_PLUGIN_DIR = `gatsby-source-filesystem` @@ -215,7 +197,7 @@ async function processRemoteNode({ } // Create the temp and permanent file names for the url. - const digest = createHash(url) + const digest = createContentDigest(url) if (!name) { name = getRemoteFileName(url) }