Skip to content

Commit cd2524c

Browse files
committed
fix(pkg/board): handler error in GetCmd creation
1 parent 62e5944 commit cd2524c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

pkg/board/remote/adb/adb.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ func (a *ADBConnection) Remove(path string) error {
227227

228228
type ADBCommand struct {
229229
cmd *paths.Process
230+
231+
err error
230232
}
231233

232234
func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
@@ -243,19 +245,31 @@ func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
243245
cmds = append(cmds, args...)
244246
}
245247

246-
command, _ := paths.NewProcess(nil, cmds...)
247-
return &ADBCommand{cmd: command}
248+
command, err := paths.NewProcess(nil, cmds...)
249+
return &ADBCommand{cmd: command, err: err}
248250
}
249251

250252
func (a *ADBCommand) Run(ctx context.Context) error {
253+
if a.err != nil {
254+
return fmt.Errorf("failed to create command: %w", a.err)
255+
}
256+
251257
return a.cmd.RunWithinContext(ctx)
252258
}
253259

254260
func (a *ADBCommand) Output(ctx context.Context) ([]byte, error) {
261+
if a.err != nil {
262+
return nil, fmt.Errorf("failed to create command: %w", a.err)
263+
}
264+
255265
return a.cmd.RunAndCaptureCombinedOutput(ctx)
256266
}
257267

258268
func (a *ADBCommand) Interactive() (io.WriteCloser, io.Reader, io.Reader, remote.Closer, error) {
269+
if a.err != nil {
270+
return nil, nil, nil, nil, fmt.Errorf("failed to create command: %w", a.err)
271+
}
272+
259273
stdin, err := a.cmd.StdinPipe()
260274
if err != nil {
261275
return nil, nil, nil, nil, fmt.Errorf("failed to get stdin pipe: %w", err)

0 commit comments

Comments
 (0)