From 782526b08a98b1aa05b21625892f9dc2d710acf1 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Fri, 22 Jul 2022 22:42:34 +0700 Subject: [PATCH] chore: skip go mod if dry run --- internal/cli/action_run.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/cli/action_run.go b/internal/cli/action_run.go index 190ac17..041534c 100644 --- a/internal/cli/action_run.go +++ b/internal/cli/action_run.go @@ -160,7 +160,7 @@ func (a *action) runUpgradeModule( } a.log("line: %s", modulePath) - // Check if line is imported module, otherwise skip + // Check if modulePath is imported module, otherwise skip if _, ok := mapImportedModules[modulePath]; !ok { a.log("%s is not imported module", modulePath) return successUpgradedModules, nil @@ -206,6 +206,10 @@ func (a *action) runUpgradeModule( } func (a *action) runGoMod(c *cli.Context, existVendor bool) error { + if a.flags.dryRun { + return nil + } + // go mod tidy goModArgs := []string{"mod", "tidy"} goOutput, err := exec.CommandContext(c.Context, "go", goModArgs...).CombinedOutput()