From f1319ffe1290fab8a82af25f7e67e8c23b708c5e Mon Sep 17 00:00:00 2001 From: wellwelwel <46850407+wellwelwel@users.noreply.github.com> Date: Wed, 1 Apr 2026 14:06:24 -0300 Subject: [PATCH] fix: apply clean option in standard coverage flow --- src/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 8dc3916..05dd3a4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import type { PokuPlugin } from 'poku/plugins'; import type { CoverageOptions } from './types.js'; -import { mkdtempSync, rmSync } from 'node:fs'; +import { mkdirSync, mkdtempSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join, resolve } from 'node:path'; import process from 'node:process'; @@ -30,6 +30,16 @@ export const coverage = ( ? options.tempDirectory! : mkdtempSync(join(tmpdir(), 'poku-c8-')); + if (options.clean !== false) { + try { + rmSync(tempDir, { recursive: true, force: true }); + } catch { + // Best-effort cleanup + } + + mkdirSync(tempDir, { recursive: true }); + } + process.env.NODE_V8_COVERAGE = tempDir; },