mirror of
https://github.com/thegeeklab/wp-plugin-go.git
synced 2024-11-21 04:00:40 +00:00
fix: dont handle LookPath in Command wrapper
This commit is contained in:
parent
119641f63a
commit
e5e67d464c
@ -34,23 +34,17 @@ func (c *Cmd) Run() error {
|
|||||||
return c.Wait()
|
return c.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command creates a new Cmd struct with the given name and arguments. It looks up the
|
// Command creates a new Cmd with the given name and arguments. The Cmd is configured
|
||||||
// absolute path of the executable using execabs.LookPath, and sets up the Cmd with
|
// with Trace set to true and TraceWriter set to os.Stdout. The Cmd's Env is set
|
||||||
// the necessary environment and output streams. The Cmd is configured to trace
|
// to the current environment.
|
||||||
// the command execution by setting Trace to true and TraceWriter to os.Stdout.
|
func Command(name string, arg ...string) *Cmd {
|
||||||
func Command(name string, arg ...string) (*Cmd, error) {
|
|
||||||
abs, err := execabs.LookPath(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("could not find executable %q: %w", name, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := &Cmd{
|
cmd := &Cmd{
|
||||||
Cmd: execabs.Command(abs, arg...),
|
Cmd: execabs.Command(name, arg...),
|
||||||
Trace: true,
|
Trace: true,
|
||||||
TraceWriter: os.Stdout,
|
TraceWriter: os.Stdout,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
|
|
||||||
return cmd, nil
|
return cmd
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user