mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
chore: clean cache dir before create mock server
This commit is contained in:
parent
d82935542e
commit
281d6d9125
@ -15,6 +15,9 @@ import qs from 'qs';
|
|||||||
import supertest, { SuperAgentTest } from 'supertest';
|
import supertest, { SuperAgentTest } from 'supertest';
|
||||||
import { MemoryPubSubAdapter } from './memory-pub-sub-adapter';
|
import { MemoryPubSubAdapter } from './memory-pub-sub-adapter';
|
||||||
import { MockDataSource } from './mock-data-source';
|
import { MockDataSource } from './mock-data-source';
|
||||||
|
import path from 'path';
|
||||||
|
import process from 'node:process';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
|
||||||
interface ActionParams {
|
interface ActionParams {
|
||||||
filterByTk?: any;
|
filterByTk?: any;
|
||||||
@ -329,6 +332,14 @@ export async function createMockCluster({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function createMockServer(options: MockServerOptions = {}): Promise<MockServer> {
|
export async function createMockServer(options: MockServerOptions = {}): Promise<MockServer> {
|
||||||
|
// clean cache directory
|
||||||
|
const cachePath = path.join(process.cwd(), 'storage', 'cache');
|
||||||
|
try {
|
||||||
|
await fs.rm(cachePath, { recursive: true, force: true });
|
||||||
|
await fs.mkdir(cachePath, { recursive: true });
|
||||||
|
} catch (e) {
|
||||||
|
// ignore errors
|
||||||
|
}
|
||||||
const { version, beforeInstall, skipInstall, skipStart, ...others } = options;
|
const { version, beforeInstall, skipInstall, skipStart, ...others } = options;
|
||||||
const app: MockServer = mockServer(others);
|
const app: MockServer = mockServer(others);
|
||||||
if (!skipInstall) {
|
if (!skipInstall) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user