@playform/document - v0.1.7
    Preparing search index...

    Interface Interface

    • Asynchronously executes a command and handles stdout/stderr output. This function spawns a child process to execute the given command and provides flexible output handling through the Echo parameter.

      Parameters

      • Command: string

        The command string to execute in the terminal or command prompt. Can be any valid shell command including pipes, redirects, and command chaining.

      • OptionalEcho: false | ((Return: any, _Error?: boolean) => Promise<void>)

        Optional parameter controlling output handling:

        • false: Suppresses all stdout/stderr output
        • Function: Custom handler called with output data and error flag
        • undefined: Default console logging of stdout/stderr

      Returns Promise<void>

      Promise - Resolves when command execution completes

      If command execution fails or process exits with non-zero code

      // Execute command with default logging
      await exec('ls -la');

      // Execute command with custom output handling
      await exec('git status', (output, isError) => {
      if (isError) console.error('Error:', output);
      else console.log('Output:', output);
      });

      // Execute command silently
      await exec('npm install', false);