Throw error if children entry can't be found, even if early access (#35452)
Co-authored-by: Peter Bengtsson <peterbe@github.com>
This commit is contained in:
@@ -30,14 +30,22 @@ export default async function createTree(originalPath, rootPath, previousTree) {
|
||||
try {
|
||||
mtime = await getMtime(filepath)
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT' && filepath.split(path.sep).includes('early-access')) {
|
||||
// Do not throw an error if Early Access is not available.
|
||||
console.warn(
|
||||
`${filepath} could not be turned into a Page, but is ignored because it's early-access`
|
||||
)
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error
|
||||
}
|
||||
// Throw an error if we can't find a content file associated with the children: entry.
|
||||
// But don't throw an error if the user is running the site locally and hasn't cloned the Early Access repo.
|
||||
if (
|
||||
process.env.NODE_ENV === 'development' &&
|
||||
originalPath === path.join('content', 'early-access')
|
||||
) {
|
||||
return
|
||||
}
|
||||
throw error
|
||||
throw new Error(
|
||||
`Cannot find a content file at ${originalPath}. Fix the children frontmatter entry "/${path.basename(
|
||||
originalPath
|
||||
)}" in ${path.dirname(originalPath)}/index.md.\n`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user