Skip to content

Commit 830767e

Browse files
committed
revert changes
1 parent f6b34f0 commit 830767e

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

internal/cmd/generate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ func codegen(ctx context.Context, combo config.CombinedSettings, sql OutputPair,
413413
case plug.Process != nil:
414414
handler = &process.Runner{
415415
Cmd: plug.Process.Cmd,
416-
Dir: combo.Dir,
417416
Env: plug.Env,
418417
Format: plug.Process.Format,
419418
}

internal/ext/process/gen.go

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"os"
99
"os/exec"
10-
"strings"
1110

1211
"google.golang.org/grpc"
1312
"google.golang.org/grpc/codes"
@@ -21,7 +20,6 @@ import (
2120

2221
type Runner struct {
2322
Cmd string
24-
Dir string // Working directory for the plugin (config file directory)
2523
Format string
2624
Env []string
2725
}
@@ -55,27 +53,14 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,
5553
return fmt.Errorf("unknown plugin format: %s", r.Format)
5654
}
5755

58-
// Parse command string to support formats like "go run ./path"
59-
cmdParts := strings.Fields(r.Cmd)
60-
if len(cmdParts) == 0 {
61-
return fmt.Errorf("process: %s not found", r.Cmd)
62-
}
63-
6456
// Check if the output plugin exists
65-
path, err := exec.LookPath(cmdParts[0])
57+
path, err := exec.LookPath(r.Cmd)
6658
if err != nil {
6759
return fmt.Errorf("process: %s not found", r.Cmd)
6860
}
6961

70-
// Build arguments: rest of cmdParts + method
71-
cmdArgs := append(cmdParts[1:], method)
72-
cmd := exec.CommandContext(ctx, path, cmdArgs...)
62+
cmd := exec.CommandContext(ctx, path, method)
7363
cmd.Stdin = bytes.NewReader(stdin)
74-
// Set working directory to config file directory for relative paths
75-
if r.Dir != "" {
76-
cmd.Dir = r.Dir
77-
}
78-
// Pass only SQLC_VERSION and explicitly configured environment variables
7964
cmd.Env = []string{
8065
fmt.Sprintf("SQLC_VERSION=%s", info.Version),
8166
}
@@ -85,20 +70,6 @@ func (r *Runner) Invoke(ctx context.Context, method string, args any, reply any,
8570
}
8671
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, os.Getenv(key)))
8772
}
88-
// For "go run" commands, inherit PATH and Go-related environment
89-
if len(cmdParts) > 1 && cmdParts[0] == "go" {
90-
for _, env := range os.Environ() {
91-
if strings.HasPrefix(env, "PATH=") ||
92-
strings.HasPrefix(env, "GOPATH=") ||
93-
strings.HasPrefix(env, "GOROOT=") ||
94-
strings.HasPrefix(env, "GOWORK=") ||
95-
strings.HasPrefix(env, "HOME=") ||
96-
strings.HasPrefix(env, "GOCACHE=") ||
97-
strings.HasPrefix(env, "GOMODCACHE=") {
98-
cmd.Env = append(cmd.Env, env)
99-
}
100-
}
101-
}
10273

10374
out, err := cmd.Output()
10475
if err != nil {

0 commit comments

Comments
 (0)