-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 #3551 * write to a temp file and rename decrease the chance of reading from an incomplete file cc #3094 #3201 * change dev-404-page to implement createPagesStatefully * update the jest snapshot
- Loading branch information
1 parent
0583a45
commit 6bbc0d1
Showing
3 changed files
with
22 additions
and
18 deletions.
There are no files selected for viewing
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
17 changes: 10 additions & 7 deletions
17
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,21 @@ | ||
const path = require(`path`) | ||
const fs = require(`fs-extra`) | ||
const chokidar = require(`chokidar`) | ||
|
||
exports.createPages = async ({ store, boundActionCreators }) => { | ||
exports.createPagesStatefully = async ({ store, boundActionCreators }, options, done) => { | ||
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) | ||
|
||
const source = path.join(__dirname, `./raw_dev-404-page.js`) | ||
const destination = path.join(program.directory, `.cache`, `dev-404-page.js`) | ||
const copy = () => fs.copy(source, destination) | ||
await copy() | ||
createPage({ | ||
component: newPath, | ||
component: destination, | ||
path: `/dev-404-page/`, | ||
}) | ||
chokidar.watch(source) | ||
.on(`change`, () => copy()) | ||
.on(`ready`, () => done()) | ||
} | ||
} |
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