Skip to content

Commit 9613fea

Browse files
committed
Refactored executils.Command
1 parent 82df01f commit 9613fea

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

commands/bundled_tools_serial_discovery.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ func ListBoards(pm *packagemanager.PackageManager) ([]*BoardPort, error) {
131131
}
132132

133133
// build the command to be executed
134-
args := []string{t.InstallDir.Join("serial-discovery").String()}
135-
cmd, err := executils.Command(args)
134+
cmd, err := executils.Command(t.InstallDir.Join("serial-discovery").String())
136135
if err != nil {
137136
return nil, errors.Wrap(err, "creating discovery process")
138137
}

commands/debug/debug.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func Debug(ctx context.Context, req *dbg.DebugConfigReq, inStream io.Reader, out
6464
}
6565
entry.Debug("Executing debugger")
6666

67-
cmd, err := executils.Command(commandLine)
67+
cmd, err := executils.Command(commandLine...)
6868
if err != nil {
6969
return nil, errors.Wrap(err, "Cannot execute debug tool")
7070
}

commands/upload/upload.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func runTool(recipeID string, props *properties.Map, outStream, errStream io.Wri
372372
if verbose {
373373
outStream.Write([]byte(fmt.Sprintln(cmdLine)))
374374
}
375-
cmd, err := executils.Command(cmdArgs)
375+
cmd, err := executils.Command(cmdArgs...)
376376
if err != nil {
377377
return fmt.Errorf("cannot execute upload tool: %s", err)
378378
}

executils/executils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TellCommandNotToSpawnShell(cmd *exec.Cmd) {
7575
// Command creates a command with the provided command line arguments.
7676
// The first argument is the path to the executable, the remainder are the
7777
// arguments to the command.
78-
func Command(args []string) (*exec.Cmd, error) {
78+
func Command(args ...string) (*exec.Cmd, error) {
7979
if args == nil || len(args) == 0 {
8080
return nil, fmt.Errorf("no executable specified")
8181
}

0 commit comments

Comments
 (0)