summaryrefslogtreecommitdiff
path: root/run.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 23:58:43 -0600
committerJeff Carr <[email protected]>2024-12-17 23:58:43 -0600
commit063e4e57c87c5e6c37709c9b327cf60ad80709d6 (patch)
treef09c2c7321bfc762d6162b673796e9d38cafe140 /run.go
parentea14fc629d4f6261242f8e45489e40fc0d5330ae (diff)
show verbose output from go mod tidy for debuggingv0.0.17
Diffstat (limited to 'run.go')
-rw-r--r--run.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/run.go b/run.go
index ac20c0a..be68eb8 100644
--- a/run.go
+++ b/run.go
@@ -68,3 +68,41 @@ func runStrict(wd string, cmd []string) {
log.Info(i, line)
}
}
+
+func runVerbose(wd string, cmd []string) error {
+ var err error
+ log.DaemonMode(true)
+ defer log.DaemonMode(false)
+ if wd != "" {
+ if err = os.Chdir(wd); err != nil {
+ return fmt.Errorf("cd %s failed %v", wd, err)
+ }
+ }
+ log.Info(wd, "running:", wd, cmd)
+ // result := shell.Run(cmd)
+ result := shell.Run(cmd)
+ if result.Error != nil {
+ log.Info("cmd failed", wd, cmd, err)
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ for i, line := range result.Stderr {
+ log.Info("STDERR:", i, line)
+ }
+ return result.Error
+ }
+ if result.Exit != 0 {
+ log.Info("cmd failed", wd, cmd, err)
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ for i, line := range result.Stderr {
+ log.Info("STDERR:", i, line)
+ }
+ return fmt.Errorf("cmd failed with %d", result.Exit)
+ }
+ for _, line := range result.Stdout {
+ log.Info(line)
+ }
+ return nil
+}