|
1 | 1 | import path from 'path';
|
2 | 2 | import fs from 'fs/promises';
|
3 |
| -import { fileURLToPath } from 'url'; |
4 | 3 |
|
5 | 4 | import { MutantRunOptions } from '@stryker-mutator/api/test-runner';
|
6 | 5 | import { normalizeFileName } from '@stryker-mutator/util';
|
7 | 6 |
|
8 | 7 | import { collectTestName, toTestId } from './vitest-helpers.js';
|
9 | 8 |
|
10 | 9 | export class FileCommunicator {
|
11 |
| - private readonly communicationDir = path.resolve( |
12 |
| - path.dirname(fileURLToPath(import.meta.url)), |
13 |
| - `.vitest-runner-${process.env.STRYKER_MUTATOR_WORKER}` |
14 |
| - ); |
| 10 | + private readonly communicationDir = path.resolve(`.vitest-runner-${process.env.STRYKER_MUTATOR_WORKER}`); |
15 | 11 |
|
16 | 12 | public readonly files = Object.freeze({
|
17 | 13 | // Replace function is to have a valid windows path
|
@@ -79,15 +75,18 @@ export class FileCommunicator {
|
79 | 75 | import { normalizeFileName } from '@stryker-mutator/util';
|
80 | 76 |
|
81 | 77 | import { beforeEach, afterAll, beforeAll, afterEach } from 'vitest';
|
82 |
| - const cwd = process.cwd(); |
83 | 78 |
|
84 | 79 | const ns = globalThis.${this.globalNamespace} || (globalThis.${this.globalNamespace} = {});
|
85 | 80 | ${body}`;
|
86 | 81 | }
|
87 | 82 |
|
88 | 83 | private async cleanCommunicationDirectories() {
|
89 |
| - await fs.rm(this.communicationDir, { recursive: true, force: true }); |
| 84 | + await this.dispose(); |
90 | 85 | await fs.mkdir(this.files.coverageDir, { recursive: true });
|
91 | 86 | await fs.mkdir(this.files.hitCountDir, { recursive: true });
|
92 | 87 | }
|
| 88 | + |
| 89 | + public async dispose(): Promise<void> { |
| 90 | + await fs.rm(this.communicationDir, { recursive: true, force: true }); |
| 91 | + } |
93 | 92 | }
|
0 commit comments