diff --git a/pkg/board/remote/adb/adb.go b/pkg/board/remote/adb/adb.go index 6efdb1f4..8326976c 100644 --- a/pkg/board/remote/adb/adb.go +++ b/pkg/board/remote/adb/adb.go @@ -227,6 +227,7 @@ func (a *ADBConnection) Remove(path string) error { type ADBCommand struct { cmd *paths.Process + err error } func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder { @@ -243,19 +244,31 @@ func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder { cmds = append(cmds, args...) } - command, _ := paths.NewProcess(nil, cmds...) - return &ADBCommand{cmd: command} + command, err := paths.NewProcess(nil, cmds...) + return &ADBCommand{cmd: command, err: err} } func (a *ADBCommand) Run(ctx context.Context) error { + if a.err != nil { + return fmt.Errorf("failed to create command: %w", a.err) + } + return a.cmd.RunWithinContext(ctx) } func (a *ADBCommand) Output(ctx context.Context) ([]byte, error) { + if a.err != nil { + return nil, fmt.Errorf("failed to create command: %w", a.err) + } + return a.cmd.RunAndCaptureCombinedOutput(ctx) } func (a *ADBCommand) Interactive() (io.WriteCloser, io.Reader, io.Reader, remote.Closer, error) { + if a.err != nil { + return nil, nil, nil, nil, fmt.Errorf("failed to create command: %w", a.err) + } + stdin, err := a.cmd.StdinPipe() if err != nil { return nil, nil, nil, nil, fmt.Errorf("failed to get stdin pipe: %w", err)