refactor: convert all fs methods to async (#6725)

* refactor: convert all fs methods to async

* fix snap
This commit is contained in:
Joshua Chen 2022-02-20 10:21:33 +08:00 committed by GitHub
parent c0b3c9af65
commit c6d0d812eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 518 additions and 429 deletions

View file

@ -185,9 +185,9 @@ describe('docsVersion', () => {
});
test('first time versioning', async () => {
const copyMock = jest.spyOn(fs, 'copySync').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDirSync').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFileSync');
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFile');
let versionedSidebar;
let versionedSidebarPath;
writeMock.mockImplementationOnce((filepath, content) => {
@ -242,9 +242,9 @@ describe('docsVersion', () => {
});
test('not the first time versioning', async () => {
const copyMock = jest.spyOn(fs, 'copySync').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDirSync').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFileSync');
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFile');
let versionedSidebar;
let versionedSidebarPath;
writeMock.mockImplementationOnce((filepath, content) => {
@ -301,9 +301,9 @@ describe('docsVersion', () => {
test('second docs instance versioning', async () => {
const pluginId = 'community';
const copyMock = jest.spyOn(fs, 'copySync').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDirSync').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFileSync');
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
const writeMock = jest.spyOn(fs, 'writeFile');
let versionedSidebar;
let versionedSidebarPath;
writeMock.mockImplementationOnce((filepath, content) => {

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs';
import fs from 'fs-extra';
import path from 'path';
import shell from 'shelljs';
@ -64,9 +64,9 @@ describe('lastUpdate', () => {
test('temporary created file that has no git timestamp', async () => {
const tempFilePath = path.join(__dirname, '__fixtures__', '.temp');
fs.writeFileSync(tempFilePath, 'Lorem ipsum :)');
await fs.writeFile(tempFilePath, 'Lorem ipsum :)');
await expect(getFileLastUpdate(tempFilePath)).resolves.toBeNull();
fs.unlinkSync(tempFilePath);
await fs.unlink(tempFilePath);
});
test('Git does not exist', async () => {