From 46fac0ea6781e90c2dc45a72142c005ddd7075b0 Mon Sep 17 00:00:00 2001 From: Simba Zhang Date: Fri, 6 Mar 2026 18:13:26 -0800 Subject: [PATCH] fix: guard benchmark main() behind require.main === module Prevents the full 131-test benchmark suite from auto-executing when the script is require()'d for syntax or import validation. Exports main() for programmatic use. --- .../scripts/run-benchmark.cjs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs b/skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs index 441dd961..2a72417b 100644 --- a/skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs +++ b/skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs @@ -1806,9 +1806,14 @@ async function main() { process.exit(failed > 0 ? 1 : 0); } -main().catch(err => { - log(`Fatal: ${err.message}`); - emit({ event: 'error', message: err.message }); - process.exit(1); -}); +// Only run when executed directly (not when require()'d for syntax/import checks) +if (require.main === module) { + main().catch(err => { + log(`Fatal: ${err.message}`); + emit({ event: 'error', message: err.message }); + process.exit(1); + }); +} + +module.exports = { main };