/ src / utils / execSyncWrapper.ts
execSyncWrapper.ts
 1  import {
 2    type ExecSyncOptions,
 3    type ExecSyncOptionsWithBufferEncoding,
 4    type ExecSyncOptionsWithStringEncoding,
 5    execSync as nodeExecSync,
 6  } from 'child_process'
 7  import { slowLogging } from './slowOperations.js'
 8  
 9  /**
10   * @deprecated Use async alternatives when possible. Sync exec calls block the event loop.
11   *
12   * Wrapped execSync with slow operation logging.
13   * Use this instead of child_process execSync directly to detect performance issues.
14   *
15   * @example
16   * import { execSync_DEPRECATED } from './execSyncWrapper.js'
17   * const result = execSync_DEPRECATED('git status', { encoding: 'utf8' })
18   */
19  export function execSync_DEPRECATED(command: string): Buffer
20  export function execSync_DEPRECATED(
21    command: string,
22    options: ExecSyncOptionsWithStringEncoding,
23  ): string
24  export function execSync_DEPRECATED(
25    command: string,
26    options: ExecSyncOptionsWithBufferEncoding,
27  ): Buffer
28  export function execSync_DEPRECATED(
29    command: string,
30    options?: ExecSyncOptions,
31  ): Buffer | string
32  export function execSync_DEPRECATED(
33    command: string,
34    options?: ExecSyncOptions,
35  ): Buffer | string {
36    using _ = slowLogging`execSync: ${command.slice(0, 100)}`
37    return nodeExecSync(command, options)
38  }