claude-code-best/src/utils/execSyncWrapper.ts
林凯90331 f7a405f703 fix(utils): replace using syntax with withDisposable for node v20 compatibility
Node.js v20 does not support the  syntax. Replace all  patterns with a new  helper that wraps the operation in try/finally and explicitly calls Symbol.dispose.

Also rename listBuiltinSkillNames to listBuiltinSkills in generate-review-builtin.ts.

Signed-off-by: 林凯90331 <90331@sangfor.com>

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 20:48:37 +08:00

41 lines
1.2 KiB
TypeScript

import {
type ExecSyncOptions,
type ExecSyncOptionsWithBufferEncoding,
type ExecSyncOptionsWithStringEncoding,
execSync as nodeExecSync,
} from 'child_process'
import { slowLogging, withDisposable } from './slowOperations.js'
/**
* @deprecated Use async alternatives when possible. Sync exec calls block the event loop.
*
* Wrapped execSync with slow operation logging.
* Use this instead of child_process execSync directly to detect performance issues.
*
* @example
* import { execSync_DEPRECATED } from './execSyncWrapper.js'
* const result = execSync_DEPRECATED('git status', { encoding: 'utf8' })
*/
export function execSync_DEPRECATED(command: string): Buffer
export function execSync_DEPRECATED(
command: string,
options: ExecSyncOptionsWithStringEncoding,
): string
export function execSync_DEPRECATED(
command: string,
options: ExecSyncOptionsWithBufferEncoding,
): Buffer
export function execSync_DEPRECATED(
command: string,
options?: ExecSyncOptions,
): Buffer | string
export function execSync_DEPRECATED(
command: string,
options?: ExecSyncOptions,
): Buffer | string {
return withDisposable(
() => nodeExecSync(command, options),
slowLogging`execSync: ${command.slice(0, 100)}`,
)
}