mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
refactor: convert all fs methods to async (#6725)
* refactor: convert all fs methods to async * fix snap
This commit is contained in:
parent
c0b3c9af65
commit
c6d0d812eb
46 changed files with 518 additions and 429 deletions
|
@ -418,7 +418,7 @@ function createVersionMetadata({
|
|||
};
|
||||
}
|
||||
|
||||
function checkVersionMetadataPaths({
|
||||
async function checkVersionMetadataPaths({
|
||||
versionMetadata,
|
||||
context,
|
||||
}: {
|
||||
|
@ -429,7 +429,7 @@ function checkVersionMetadataPaths({
|
|||
const {siteDir} = context;
|
||||
const isCurrentVersion = versionName === CURRENT_VERSION_NAME;
|
||||
|
||||
if (!fs.existsSync(contentPath)) {
|
||||
if (!(await fs.pathExists(contentPath))) {
|
||||
throw new Error(
|
||||
`The docs folder does not exist for version "${versionName}". A docs folder is expected to be found at ${path.relative(
|
||||
siteDir,
|
||||
|
@ -446,7 +446,7 @@ function checkVersionMetadataPaths({
|
|||
if (
|
||||
isCurrentVersion &&
|
||||
typeof sidebarFilePath === 'string' &&
|
||||
!fs.existsSync(sidebarFilePath)
|
||||
!(await fs.pathExists(sidebarFilePath))
|
||||
) {
|
||||
throw new Error(`The path to the sidebar file does not exist at "${path.relative(
|
||||
siteDir,
|
||||
|
@ -585,8 +585,10 @@ export async function readVersionsMetadata({
|
|||
options,
|
||||
}),
|
||||
);
|
||||
versionsMetadata.forEach((versionMetadata) =>
|
||||
checkVersionMetadataPaths({versionMetadata, context}),
|
||||
await Promise.all(
|
||||
versionsMetadata.map((versionMetadata) =>
|
||||
checkVersionMetadataPaths({versionMetadata, context}),
|
||||
),
|
||||
);
|
||||
return versionsMetadata;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue