Skip to content

Commit 8df233d

Browse files
authored
Merge pull request #127 from SharpAI/fix/benchmark-require-guard
Fix/benchmark require guard
2 parents f043519 + 277956c commit 8df233d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

skills/analysis/home-security-benchmark/scripts/run-benchmark.cjs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Tests: 131 total (96 LLM + 35 VLM) across 16 suites
7373
process.exit(0);
7474
}
7575

76+
7677
// Parse skill parameters if running as Aegis skill
7778
let skillParams = {};
7879
try { skillParams = JSON.parse(process.env.AEGIS_SKILL_PARAMS || '{}'); } catch { }
@@ -1825,8 +1826,13 @@ async function main() {
18251826
process.exit(failed > 0 ? 1 : 0);
18261827
}
18271828

1828-
// Only run when executed directly (not when require()'d for syntax/import checks)
1829-
if (require.main === module) {
1829+
// Run when executed directly — supports both plain Node and Electron spawn.
1830+
// `require.main === module` works for `node script.cjs`.
1831+
// `process.argv[1]` check handles `spawn(electronBinary, [scriptPath])`.
1832+
const isDirectRun = require.main === module ||
1833+
(process.argv[1] && require('path').resolve(process.argv[1]) === __filename);
1834+
1835+
if (isDirectRun) {
18301836
main().catch(err => {
18311837
log(`Fatal: ${err.message}`);
18321838
emit({ event: 'error', message: err.message });

0 commit comments

Comments
 (0)