backend-test-utils: rename MockDirectory.cleanup -> .remove
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -37,7 +37,6 @@ export function isDockerDisabledForTests(): boolean;
|
||||
// @public
|
||||
export class MockDirectory {
|
||||
addContent(root: MockDirectoryContent): Promise<void>;
|
||||
cleanup: () => Promise<void>;
|
||||
clear: () => Promise<void>;
|
||||
content(
|
||||
options?: MockDirectoryContentOptions,
|
||||
@@ -45,6 +44,7 @@ export class MockDirectory {
|
||||
static create(options?: MockDirectoryCreateOptions): MockDirectory;
|
||||
static mockOsTmpDir(): MockDirectory;
|
||||
get path(): string;
|
||||
remove: () => Promise<void>;
|
||||
resolve(...paths: string[]): string;
|
||||
setContent(root: MockDirectoryContent): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -138,10 +138,10 @@ export class MockDirectory {
|
||||
|
||||
const shouldCleanup = !options?.root || !fs.pathExistsSync(options.root);
|
||||
if (shouldCleanup) {
|
||||
process.on('beforeExit', mocker.#cleanupSync);
|
||||
process.on('beforeExit', mocker.#removeSync);
|
||||
|
||||
try {
|
||||
afterAll(mocker.cleanup);
|
||||
afterAll(mocker.remove);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
@@ -208,7 +208,7 @@ export class MockDirectory {
|
||||
* ```
|
||||
*/
|
||||
async setContent(root: MockDirectoryContent): Promise<void> {
|
||||
await this.cleanup();
|
||||
await this.remove();
|
||||
|
||||
return this.addContent(root);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ export class MockDirectory {
|
||||
/**
|
||||
* Removes the mock directory and all its contents.
|
||||
*/
|
||||
cleanup = async (): Promise<void> => {
|
||||
remove = async (): Promise<void> => {
|
||||
await fs.rm(this.#root, { recursive: true, force: true });
|
||||
};
|
||||
|
||||
@@ -361,7 +361,7 @@ export class MockDirectory {
|
||||
return entries;
|
||||
}
|
||||
|
||||
#cleanupSync = () => {
|
||||
#removeSync = () => {
|
||||
fs.rmSync(this.#root, { recursive: true, force: true });
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user