From 5fbfec3aaf40bdf6824308f6e24aeb6d40903e57 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 17:53:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(main):=20=E6=94=B9=E7=94=A8=20AI=5FREVIEW?= =?UTF-8?q?=5FSKIP=5FMAIN=20=E5=AE=88=E8=A1=9B=20auto-run=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=BE=A9=20node=20action=20runtime=20=E4=B8=8D?= =?UTF-8?q?=E5=9F=B7=E8=A1=8C=20main=20=E7=9A=84=E5=9B=9E=E6=AD=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.js b/src/main.js index 2c1ffee..34fc52b 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,4 @@ import path from 'path'; -import { pathToFileURL } from 'url'; import { GITEA_REPOSITORY, PR_NUMBER, PR_HEAD_BRANCH, PR_BASE_BRANCH, getLLMConfig, FINDINGS_PATH, EXCLUSIONS_PATH } from './config.js'; import { loadRoles, getRoleIntro } from './roles.js'; import { getPRDiff, postComment, getCommitMessageBySha, getBotReviewOutcome, shouldSkipBotCommit } from './gitea.js'; @@ -237,9 +236,9 @@ export async function main() { section('Pipeline 結束'); } -// 僅在作為 CLI 進入點(node src/main.js)執行時自動啟動 pipeline; -// 被 import(例如單元測試)時不自動執行,方便注入 mock 測試各分支。 -if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { +// 預設一律自動啟動 pipeline(正式以 node 執行、或由 Gitea node action runtime 載入時皆會執行)。 +// 僅單元測試會設 AI_REVIEW_SKIP_MAIN=1 略過自動執行,改為手動呼叫 export 的 main() 注入 mock 測試。 +if (!process.env.AI_REVIEW_SKIP_MAIN) { main().catch(e => { error(`Runner failed: ${e.message}`); process.exit(1);