MCPcopy Create free account
hub / github.com/Gan-Xing/CodexBridge / runCommand

Function runCommand

packages/codex-native-api/src/daemon_manager.ts:1006–1035  ·  view source on GitHub ↗
(
  command: string,
  args: string[],
  {
    allowFailure = false,
  }: {
    allowFailure?: boolean;
  } = {},
)

Source from the content-addressed store, hash-verified

1004}
1005
1006async function runCommand(
1007 command: string,
1008 args: string[],
1009 {
1010 allowFailure = false,
1011 }: {
1012 allowFailure?: boolean;
1013 } = {},
1014): Promise<void> {
1015 await new Promise<void>((resolve, reject) => {
1016 const child = spawn(command, args, {
1017 stdio: 'inherit',
1018 windowsHide: true,
1019 });
1020 child.once('error', (error) => {
1021 if (allowFailure) {
1022 resolve();
1023 return;
1024 }
1025 reject(error);
1026 });
1027 child.once('exit', (code) => {
1028 if (!allowFailure && code !== 0) {
1029 reject(new Error(`Command failed (${command} ${args.join(' ')}): exit ${code}`));
1030 return;
1031 }
1032 resolve();
1033 });
1034 });
1035}
1036
1037async function runPowerShellScript(script: string): Promise<void> {
1038 const powershell = process.platform === 'win32' ? 'powershell.exe' : 'powershell';

Callers 8

installDaemonFunction · 0.85
startDaemonFunction · 0.85
stopDaemonFunction · 0.85
restartDaemonFunction · 0.85
statusDaemonFunction · 0.85
logsDaemonFunction · 0.85
uninstallDaemonFunction · 0.85
runPowerShellScriptFunction · 0.85

Calls 2

resolveFunction · 0.85
rejectFunction · 0.85

Tested by

no test coverage detected