Skip to content

Commit a74c28a

Browse files
committed
Avoid RunCmd duplication
1 parent d37f522 commit a74c28a

1 file changed

Lines changed: 2 additions & 18 deletions

File tree

‎go/extractor/registries/registryproxy.go‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212

1313
"github.com/github/codeql-go/extractor/diagnostics"
14+
"github.com/github/codeql-go/extractor/util"
1415
)
1516

1617
const PROXY_HOST = "CODEQL_PROXY_HOST"
@@ -286,24 +287,7 @@ func (self ProxiedCmd) Run() error {
286287
// Runs the command and waits for it to complete. Returns a boolean indicating whether the command was successful
287288
// and logs errors if any occur.
288289
func (self ProxiedCmd) RunCmd() bool {
289-
return run[bool](&self, func(cmd *exec.Cmd) bool {
290-
cmd.Stdout = os.Stdout
291-
cmd.Stderr = os.Stderr
292-
in, _ := cmd.StdinPipe()
293-
err := cmd.Start()
294-
if err != nil {
295-
slog.Warn(fmt.Sprintf("Running %s %v failed, continuing anyway: %s\n", cmd.Path, cmd.Args, err.Error()))
296-
return false
297-
}
298-
in.Close()
299-
err = cmd.Wait()
300-
if err != nil {
301-
slog.Warn(fmt.Sprintf("Running %s %v failed, continuing anyway: %s\n", cmd.Path, cmd.Args, err.Error()))
302-
return false
303-
}
304-
305-
return true
306-
})
290+
return run[bool](&self, util.RunCmd)
307291
}
308292

309293
type Output struct {

0 commit comments

Comments
 (0)