From ee263e5708d249ac2d2180bca265ed2b604ca3b0 Mon Sep 17 00:00:00 2001 From: Lixin2026 <126993554+2023Anita@users.noreply.github.com> Date: Sun, 21 Jun 2026 07:20:45 +0800 Subject: [PATCH] test: clean hooks temp dir on failure (#213) --- tests/hooks.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/hooks.test.js b/tests/hooks.test.js index 4f0d9b3..59df610 100644 --- a/tests/hooks.test.js +++ b/tests/hooks.test.js @@ -21,6 +21,14 @@ function run(script, env, input = '') { delete process.env.CLAUDE_CONFIG_DIR; const temp = fs.mkdtempSync(path.join(os.tmpdir(), 'ponytail-hooks-')); +let cleanedTemp = false; +function cleanupTemp() { + if (cleanedTemp) return; + cleanedTemp = true; + fs.rmSync(temp, { recursive: true, force: true }); +} +process.once('exit', cleanupTemp); + const home = path.join(temp, 'home'); const pluginData = path.join(temp, 'plugin-data'); fs.mkdirSync(home, { recursive: true }); @@ -155,5 +163,5 @@ assert.equal( output = JSON.parse(result.stdout); assert.deepEqual(output, {}); -fs.rmSync(temp, { recursive: true, force: true }); +cleanupTemp(); console.log('hook compatibility checks passed');