Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that Gatsby can't sometimes find layout and page files on Windows #3796

Merged
merged 2 commits into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ exports.createLayouts = async (
) => {
const { createLayout, deleteLayout } = boundActionCreators
const program = store.getState().program
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
const layoutDirectory = systemPath.posix.join(
program.directory,
`/src/layouts`
)
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
const layoutGlob = `${layoutDirectory}/**/*.{${exts}}`

// Get initial list of files.
let files = await glob(`${layoutDirectory}/**/?(${exts})`)
let files = await glob(layoutGlob)
files.forEach(file => _createLayout(file, layoutDirectory, createLayout))

// Listen for new layouts to be added or removed.
chokidar
.watch(`${layoutDirectory}/**/*.{${exts}}`)
.watch(layoutGlob)
.on(`add`, path => {
if (!_.includes(files, path)) {
_createLayout(path, layoutDirectory, createLayout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ exports.createPagesStatefully = async (
) => {
const { createPage, deletePage } = boundActionCreators
const program = store.getState().program
const pagesDirectory = systemPath.posix.join(program.directory, `/src/pages`)
const exts = program.extensions.map(e => `${e.slice(1)}`).join(`,`)
const pagesDirectory = systemPath.posix.join(program.directory, `/src/pages`)
const pagesGlob = `${pagesDirectory}/**/*.{${exts}}`

// Get initial list of files.
let files = await glob(`${pagesDirectory}/**/?(${exts})`)
let files = await glob(pagesGlob)
files.forEach(file => _createPage(file, pagesDirectory, createPage))

// Listen for new component pages to be added or removed.
chokidar
.watch(`${pagesDirectory}/**/*.{${exts}}`)
.watch(pagesGlob)
.on(`add`, path => {
if (!_.includes(files, path)) {
_createPage(path, pagesDirectory, createPage)
Expand Down