MCPcopy
hub / github.com/di-sukharev/opencommit / execa

Function execa

out/cli.cjs:66870–66946  ·  view source on GitHub ↗
(file, args, options)

Source from the content-addressed store, hash-verified

66868 if (typeof value !== "string" && !import_node_buffer2.Buffer.isBuffer(value)) {
66869 return error === void 0 ? void 0 : "";
66870 }
66871 if (options.stripFinalNewline) {
66872 return stripFinalNewline(value);
66873 }
66874 return value;
66875};
66876function execa(file, args, options) {
66877 const parsed = handleArguments(file, args, options);
66878 const command = joinCommand(file, args);
66879 const escapedCommand = getEscapedCommand(file, args);
66880 logCommand(escapedCommand, parsed.options);
66881 validateTimeout(parsed.options);
66882 let spawned;
66883 try {
66884 spawned = import_node_child_process3.default.spawn(parsed.file, parsed.args, parsed.options);
66885 } catch (error) {
66886 const dummySpawned = new import_node_child_process3.default.ChildProcess();
66887 const errorPromise = Promise.reject(makeError({
66888 error,
66889 stdout: "",
66890 stderr: "",
66891 all: "",
66892 command,
66893 escapedCommand,
66894 parsed,
66895 timedOut: false,
66896 isCanceled: false,
66897 killed: false
66898 }));
66899 mergePromise(dummySpawned, errorPromise);
66900 return dummySpawned;
66901 }
66902 const spawnedPromise = getSpawnedPromise(spawned);
66903 const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
66904 const processDone = setExitHandler(spawned, parsed.options, timedPromise);
66905 const context = { isCanceled: false };
66906 spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
66907 spawned.cancel = spawnedCancel.bind(null, spawned, context);
66908 const handlePromise = async () => {
66909 const [{ error, exitCode, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
66910 const stdout = handleOutput(parsed.options, stdoutResult);
66911 const stderr2 = handleOutput(parsed.options, stderrResult);
66912 const all3 = handleOutput(parsed.options, allResult);
66913 if (error || exitCode !== 0 || signal !== null) {
66914 const returnedError = makeError({
66915 error,
66916 exitCode,
66917 signal,
66918 stdout,
66919 stderr: stderr2,
66920 all: all3,
66921 command,
66922 escapedCommand,
66923 parsed,
66924 timedOut,
66925 isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false),
66926 killed: spawned.killed
66927 });

Callers 15

$6Function · 0.85
assertGitRepoFunction · 0.85
getCoreHooksPathFunction · 0.85
getStagedFilesFunction · 0.85
getChangedFilesFunction · 0.85
gitAddFunction · 0.85
getDiffFunction · 0.85
getGitDirFunction · 0.85
getGitRemotesFunction · 0.85
hasUpstreamBranchFunction · 0.85
getCurrentBranchFunction · 0.85

Calls 13

handleArgumentsFunction · 0.85
joinCommandFunction · 0.85
getEscapedCommandFunction · 0.85
logCommandFunction · 0.85
validateTimeoutFunction · 0.85
makeErrorFunction · 0.85
mergePromiseFunction · 0.85
getSpawnedPromiseFunction · 0.85
setupTimeoutFunction · 0.85
setExitHandlerFunction · 0.85
handleInputFunction · 0.85
makeAllStreamFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…