things I noticed to cleanup while making the pr

This commit is contained in:
Yannick Dorn 2022-11-29 22:07:18 -05:00
parent f0003e66c7
commit 2c041f22bf
3 changed files with 1 additions and 11 deletions

View File

@ -7,7 +7,6 @@ const protocol = ssl ? "wss:" : "ws:";
export default function command(url, command, onmessage, onclose) {
url = removePrefix(url);
console.log(command)
url = `${protocol}//${window.location.host}${baseURL}/api/command${url}?auth=${store.state.jwt}`;
let conn = new window.WebSocket(url);

View File

@ -2,7 +2,6 @@ package http
import (
"bufio"
"fmt"
"io"
"log"
"net/http"
@ -62,7 +61,6 @@ var commandsHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *d
command, err := runner.ParseCommand(d.settings, raw, r.URL.Path)
// fmt.Println("Full Command: ", command)
if err != nil {
if err := conn.WriteMessage(websocket.TextMessage, []byte(err.Error())); err != nil { //nolint:govet
@ -80,25 +78,21 @@ var commandsHandler = withUser(func(w http.ResponseWriter, r *http.Request, d *d
}
cmd := exec.Command(command[0], command[1:]...) //nolint:gosec
// needs glob expansion somehow
cmd.Dir = d.user.FullPath(r.URL.Path)
stdout, err := cmd.StdoutPipe()
if err != nil {
fmt.Println("or here")
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
stderr, err := cmd.StderrPipe()
if err != nil {
fmt.Println("failed here")
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}
if err := cmd.Start(); err != nil {
fmt.Println("or there")
wsErr(conn, r, http.StatusInternalServerError, err)
return 0, nil
}

View File

@ -1,7 +1,6 @@
package runner
import (
"fmt"
"os/exec"
"path/filepath"
"strings"
@ -22,7 +21,7 @@ func GlobExpand(args []string, cwd string) ([]string, error) {
if err != nil {
return nil, err
}
//No match means the argument is just appended to the end.
//No match means the argument is fine so just appended to the end.
if len(matches) == 0 {
expandedArgs = append(expandedArgs, arg)
} else {
@ -86,7 +85,5 @@ func ParseCommand(s *settings.Settings, raw string, cwd string) ([]string, error
command = append(s.Shell, raw) //nolint:gocritic
}
fmt.Println("Final Command: ", command)
return command, nil
}