Skip to content

Commit

Permalink
use createPage singleton in dev-404-page
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensurgnier committed Jan 29, 2018
1 parent 6c1f3bc commit d1a588d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
const path = require(`path`)
const fs = require(`fs-extra`)

let createdPage = false

exports.createPages = async ({ store, boundActionCreators }) => {
if (process.env.NODE_ENV !== `production`) {
const { program } = store.getState()
const { createPage } = boundActionCreators
const currentPath = path.join(__dirname, `./raw_dev-404-page.js`)
const newPath = path.join(program.directory, `.cache`, `dev-404-page.js`)

await fs.copy(currentPath, newPath)
if (!createdPage) {
createdPage = true

await fs.copy(currentPath, newPath)

createPage({
component: newPath,
path: `/dev-404-page/`,
})
createPage({
component: newPath,
path: `/dev-404-page/`,
})
}
}
}

0 comments on commit d1a588d

Please sign in to comment.