RAGS - v1.10.0
    Preparing search index...

    Function exec

    • Executes a command synchronously and returns the result.

      Blocks the main loop until the command completes. Use execAsync for non-blocking execution.

      Type Parameters

      • Out = string
      • Err = string

      Parameters

      Returns Out | Err

      The transformed stdout on success, or transformed stderr on failure

      const user = exec('whoami');
      const parsed = exec('cat config.json', JSON.parse);
    • Executes a command synchronously and returns the result.

      Blocks the main loop until the command completes. Use execAsync for non-blocking execution.

      Type Parameters

      • Out = string
      • Err = string

      Parameters

      • cmd: string | string[]
      • Optionalout: (stdout: string) => Out
      • Optionalerr: (stderr: string) => Err

      Returns Out | Err

      The transformed stdout on success, or transformed stderr on failure

      const user = exec('whoami');
      const parsed = exec('cat config.json', JSON.parse);