Skip to content

Commit

Permalink
Better finding the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
lixin9311 committed Sep 22, 2019
1 parent 550ec5f commit 5f7ec9f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,16 @@ func killPlugin() {
}
}

func execPlugin(plugin, pluginOpts, remoteHost, remotePort, localHost, localPort string) error {
func execPlugin(plugin, pluginOpts, remoteHost, remotePort, localHost, localPort string) (err error) {
pluginFile := plugin
if fileExists(plugin) {
if !filepath.IsAbs(plugin) {
plugin = "./" + plugin
pluginFile = "./" + plugin
}
} else {
pluginFile, err = exec.LookPath(plugin)
if err != nil {
return err
}
}
logH := newLogHelper("[" + plugin + "]: ")
Expand All @@ -68,13 +74,12 @@ func execPlugin(plugin, pluginOpts, remoteHost, remotePort, localHost, localPort
"SS_PLUGIN_OPTIONS="+pluginOpts,
)
cmd := &exec.Cmd{
Path: plugin,
Args: []string{plugin},
Path: pluginFile,
Env: env,
Stdout: logH,
Stderr: logH,
}
if err := cmd.Start(); err != nil {
if err = cmd.Start(); err != nil {
return err
}
pluginCmd = cmd
Expand Down

0 comments on commit 5f7ec9f

Please sign in to comment.