MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / execFileNoThrowWithCwd

Function execFileNoThrowWithCwd

source code/utils/execFileNoThrow.ts:91–152  ·  view source on GitHub ↗
(
  file: string,
  args: string[],
  {
    abortSignal,
    timeout: finalTimeout = 10 * SECONDS_IN_MINUTE * MS_IN_SECOND,
    preserveOutputOnError: finalPreserveOutput = true,
    cwd: finalCwd,
    env: finalEnv,
    maxBuffer,
    shell,
    stdin: finalStdin,
    input: finalInput,
  }: ExecFileWithCwdOptions = {
    timeout: 10 * SECONDS_IN_MINUTE * MS_IN_SECOND,
    preserveOutputOnError: true,
    maxBuffer: 1_000_000,
  },
)

Source from the content-addressed store, hash-verified

89 * execFile, but always resolves (never throws)
90 */
91export function execFileNoThrowWithCwd(
92 file: string,
93 args: string[],
94 {
95 abortSignal,
96 timeout: finalTimeout = 10 * SECONDS_IN_MINUTE * MS_IN_SECOND,
97 preserveOutputOnError: finalPreserveOutput = true,
98 cwd: finalCwd,
99 env: finalEnv,
100 maxBuffer,
101 shell,
102 stdin: finalStdin,
103 input: finalInput,
104 }: ExecFileWithCwdOptions = {
105 timeout: 10 * SECONDS_IN_MINUTE * MS_IN_SECOND,
106 preserveOutputOnError: true,
107 maxBuffer: 1_000_000,
108 },
109): Promise<{ stdout: string; stderr: string; code: number; error?: string }> {
110 return new Promise(resolve => {
111 // Use execa for cross-platform .bat/.cmd compatibility on Windows
112 execa(file, args, {
113 maxBuffer,
114 signal: abortSignal,
115 timeout: finalTimeout,
116 cwd: finalCwd,
117 env: finalEnv,
118 shell,
119 stdin: finalStdin,
120 input: finalInput,
121 reject: false, // Don't throw on non-zero exit codes
122 })
123 .then(result => {
124 if (result.failed) {
125 if (finalPreserveOutput) {
126 const errorCode = result.exitCode ?? 1
127 void resolve({
128 stdout: result.stdout || '',
129 stderr: result.stderr || '',
130 code: errorCode,
131 error: getErrorMessage(
132 result as unknown as ExecaResultWithError,
133 errorCode,
134 ),
135 })
136 } else {
137 void resolve({ stdout: '', stderr: '', code: result.exitCode ?? 1 })
138 }
139 } else {
140 void resolve({
141 stdout: result.stdout,
142 stderr: result.stderr,
143 code: 0,
144 })
145 }
146 })
147 .catch((error: ExecaError) => {
148 logError(error)

Callers 15

getWorktreePathsFunction · 0.85
fetchSingleFileGitDiffFunction · 0.85
getDiffRefFunction · 0.85
execFileNoThrowFunction · 0.85
copyPngToClipboardFunction · 0.85
getOrCreateWorktreeFunction · 0.85
tearDownFunction · 0.85
copyWorktreeIncludeFilesFunction · 0.85
performPostCreationSetupFunction · 0.85

Calls 3

resolveFunction · 0.70
getErrorMessageFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected