Skip to content

feat: execute original sub command while not executing go build #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 31, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tool/preprocess/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,19 @@ func nullDevice() string {
return "/dev/null"
}

func runOriginalCmd(originalGoCmd []string) error {
out, err := runCmdCombinedOutput("", originalGoCmd...)
util.SetLogger(os.Stdout)
if out != "" {
_, _ = fmt.Fprintln(os.Stdout, out)
}
util.SetLogger(os.Stderr)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, err.Error())
}
return err
}

func runBuildWithToolexec(goBuildCmd []string) error {
exe, err := os.Executable()
if err != nil {
Expand Down Expand Up @@ -908,7 +921,11 @@ func precheck() error {
os.Exit(0)
}
if os.Args[2] != "build" {
config.PrintVersion()
// exec original go command
err := runOriginalCmd(os.Args[1:])
if err != nil {
os.Exit(1)
}
os.Exit(0)
}
return nil
Expand Down
Loading