1
0
mirror of synced 2025-12-22 11:26:57 -05:00

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:
Sarah Schneider
2023-03-10 16:27:58 -05:00
committed by GitHub
parent 5cecf691c2
commit 9c5f1ade48
2 changed files with 19 additions and 7 deletions

View File

@@ -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`
)
}
}