mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +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
|
@ -143,7 +143,7 @@ describe('load utils', () => {
|
|||
describe('generate', () => {
|
||||
test('behaves correctly', async () => {
|
||||
const writeMock = jest.spyOn(fs, 'writeFile').mockImplementation(() => {});
|
||||
const existsMock = jest.spyOn(fs, 'existsSync');
|
||||
const existsMock = jest.spyOn(fs, 'pathExists');
|
||||
const readMock = jest.spyOn(fs, 'readFile');
|
||||
|
||||
// First call: no file, no cache
|
||||
|
|
|
@ -106,7 +106,7 @@ export async function generate(
|
|||
// If file already exists but its not in runtime cache yet,
|
||||
// we try to calculate the content hash and then compare
|
||||
// This is to avoid unnecessary overwriting and we can reuse old file.
|
||||
if (!lastHash && fs.existsSync(filepath)) {
|
||||
if (!lastHash && (await fs.pathExists(filepath))) {
|
||||
const lastContent = await fs.readFile(filepath, 'utf8');
|
||||
lastHash = createHash('md5').update(lastContent).digest('hex');
|
||||
fileHash.set(filepath, lastHash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue