things I noticed to cleanup while making the pr
This commit is contained in:
parent
f0003e66c7
commit
2c041f22bf
@ -7,7 +7,6 @@ const protocol = ssl ? "wss:" : "ws:";
|
|||||||
|
|
||||||
export default function command(url, command, onmessage, onclose) {
|
export default function command(url, command, onmessage, onclose) {
|
||||||
url = removePrefix(url);
|
url = removePrefix(url);
|
||||||
console.log(command)
|
|
||||||
url = `${protocol}//${window.location.host}${baseURL}/api/command${url}?auth=${store.state.jwt}`;
|
url = `${protocol}//${window.location.host}${baseURL}/api/command${url}?auth=${store.state.jwt}`;
|
||||||
|
|
||||||
let conn = new window.WebSocket(url);
|
let conn = new window.WebSocket(url);
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"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)
|
command, err := runner.ParseCommand(d.settings, raw, r.URL.Path)
|
||||||
|
|
||||||
// fmt.Println("Full Command: ", command)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err := conn.WriteMessage(websocket.TextMessage, []byte(err.Error())); err != nil { //nolint:govet
|
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
|
cmd := exec.Command(command[0], command[1:]...) //nolint:gosec
|
||||||
// needs glob expansion somehow
|
|
||||||
cmd.Dir = d.user.FullPath(r.URL.Path)
|
cmd.Dir = d.user.FullPath(r.URL.Path)
|
||||||
|
|
||||||
stdout, err := cmd.StdoutPipe()
|
stdout, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("or here")
|
|
||||||
wsErr(conn, r, http.StatusInternalServerError, err)
|
wsErr(conn, r, http.StatusInternalServerError, err)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr, err := cmd.StderrPipe()
|
stderr, err := cmd.StderrPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("failed here")
|
|
||||||
wsErr(conn, r, http.StatusInternalServerError, err)
|
wsErr(conn, r, http.StatusInternalServerError, err)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
fmt.Println("or there")
|
|
||||||
wsErr(conn, r, http.StatusInternalServerError, err)
|
wsErr(conn, r, http.StatusInternalServerError, err)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
package runner
|
package runner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -22,7 +21,7 @@ func GlobExpand(args []string, cwd string) ([]string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
if len(matches) == 0 {
|
||||||
expandedArgs = append(expandedArgs, arg)
|
expandedArgs = append(expandedArgs, arg)
|
||||||
} else {
|
} else {
|
||||||
@ -86,7 +85,5 @@ func ParseCommand(s *settings.Settings, raw string, cwd string) ([]string, error
|
|||||||
command = append(s.Shell, raw) //nolint:gocritic
|
command = append(s.Shell, raw) //nolint:gocritic
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Final Command: ", command)
|
|
||||||
|
|
||||||
return command, nil
|
return command, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user