forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use createPage singleton in dev-404-page
closes gatsbyjs#3551
- Loading branch information
1 parent
6c1f3bc
commit d1a588d
Showing
1 changed file
with
11 additions
and
5 deletions.
There are no files selected for viewing
16 changes: 11 additions & 5 deletions
16
packages/gatsby/src/internal-plugins/dev-404-page/gatsby-node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/`, | ||
}) | ||
} | ||
} | ||
} |