mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-04 01:09:20 +02:00
refactor: prefer fs.readJSON over readFile.then(JSON.parse) (#7186)
* refactor: prefer fs.readJSON over readFile.then(JSON.parse) * refactor: use promises
This commit is contained in:
parent
674a77f02d
commit
200009008b
9 changed files with 27 additions and 33 deletions
|
@ -111,9 +111,7 @@ async function doRender(locals: Locals & {path: string}) {
|
|||
|
||||
const {generatedFilesDir} = locals;
|
||||
const manifestPath = path.join(generatedFilesDir, 'client-manifest.json');
|
||||
const manifest: Manifest = JSON.parse(
|
||||
await fs.readFile(manifestPath, 'utf8'),
|
||||
);
|
||||
const manifest: Manifest = await fs.readJSON(manifestPath);
|
||||
|
||||
// Get all required assets for this particular page based on client
|
||||
// manifest information.
|
||||
|
|
|
@ -58,7 +58,7 @@ async function readTranslationFileContent(
|
|||
): Promise<TranslationFileContent | undefined> {
|
||||
if (await fs.pathExists(filePath)) {
|
||||
try {
|
||||
const content = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
||||
const content = await fs.readJSON(filePath);
|
||||
ensureTranslationFileContent(content);
|
||||
return content;
|
||||
} catch (err) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue