Compare commits

...

1 Commits

Author SHA1 Message Date
jiantw83 d04f4dd2bb feat: 回復使用 spawnSync 執行指令 2026-05-11 13:47:40 +00:00
+5 -2
View File
@@ -1,9 +1,12 @@
import { execSync } from 'child_process'; import { spawnSync } from 'child_process';
import path from 'path'; import path from 'path';
import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js'; import { GITEA_SERVER_URL, GITEA_REPOSITORY, GITEA_TOKEN, PR_HEAD_BRANCH, FINDINGS_PATH } from './config.js';
function git(args, cwd) { function git(args, cwd) {
return execSync(`git ${args.map(a => `'${a.replace(/'/g, "'\\''")}'`).join(' ')}`, { cwd, encoding: 'utf8' }).trim(); const result = spawnSync('git', args, { cwd, encoding: 'utf8' });
if (result.error) throw result.error;
if (result.status !== 0) throw new Error((result.stderr || result.stdout || '').trim());
return (result.stdout || '').trim();
} }
export async function commitAndPush(workspace) { export async function commitAndPush(workspace) {